> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://en.megaport.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://en.megaport.ferndocs.com/_mcp/server.

# Invite (Add) a New User to an Existing Company

POST https://api.megaport.com/v2/employment
Content-Type: application/json

Invites a new user to an existing company.

A Company Admin can add users to their company using this endpoint. This endpoint triggers an email to be sent to the invited user with a temporary password. The new user must reset their password during their first login.

Select the Megaport user role to assign to the invited user by the `position` value. These roles are available:

- **Company Admin** â€“ Company Admins have access to all user privileges. We recommend limiting the number of Company Admins to only those who require full access, but defining at least two for redundancy.
- **Technical Admin** â€“ This role is for technical users who know how to create and approve orders.
- **Technical Contact** â€“ This role is for technical users who know how to design and modify services but donâ€™t have the authority to approve orders.
- **Finance** â€“ Finance users should have a financial responsibility within the organization while also understanding the consequences of their actions if they delete or approve services.  
    **Note:** While creating services, direct customers can see the cost of the service before deploying. It is also possible to see the cost of deployed services by selecting a service in the Portal and viewing the Details tab.

- **Financial Contact** â€“ This user role is similar to the Finance role without the ability to place and approve orders, delete services, or administer service keys.
- **Read Only** â€“ Read Only is the most restrictive role. Note that a Read Only user can view service details which you may want to keep secure and private.

For more details, see [Inviting Users to Your Account](https://docs.megaport.com/setting-up/inviting-users/) in the Megaport documentation.

Reference: https://en.megaport.ferndocs.com/api-reference/user-authentication/invite-add-a-new-user-to-an-existing-company

## Servers

- `https://api.megaport.com` (Production environment, default)
- `https://api-staging.megaport.com` (Staging environment (test only, reset every 24 hours))

## Request

### Body (application/json)

This endpoint expects an object.

- `active` (boolean, optional)
- `email` (string, optional)
- `firstName` (string, optional)
- `lastName` (string, optional)
- `phone` (string, optional)
- `position` (string, optional)

## Response

### 201

Invite a New User to an Existing Company - Success / Invite a New User to an Existing Company - Success

- `data` (V2EmploymentPostResponsesContentApplicationJsonSchemaData, optional)
- `message` (string, optional)
- `terms` (string, optional)

## Errors

### 400 Bad Request Error

Invite a New User to an Existing Company - When Mandatory Fields are Missing / Invite a New User to an Existing Company - When Mandatory Fields are Missing

- `message` (string, optional)
- `terms` (string, optional)

### 401 Unauthorized Error

Invite a New User to an Existing Company - If the Provided Bearer Token (Access token) is Invalid / Invite a New User to an Existing Company - If the Provided Bearer Token (Access token) is Invalid

- `message` (string, optional)
- `terms` (string, optional)

### 403 Forbidden Error

Invite a New User to an Existing Company - You do not Have Permission for this Operation / Invite a New User to an Existing Company - You do not Have Permission for this Operation

- `message` (string, optional)
- `terms` (string, optional)

## Types

### V2EmploymentPostResponsesContentApplicationJsonSchemaData

- `companyId` (double, optional)
- `employeeId` (double, optional)
- `employmentId` (double, optional)

## Examples

### Invite a New User to an Existing Company - Success

**Response**

```json
{
  "data": {
    "companyId": 54662,
    "employeeId": 54663,
    "employmentId": 49376
  },
  "message": "Employment 49376 Created -  employee 54663 created for Company 54662",
  "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy"
}
```

**SDK Code**

```python Invite a New User to an Existing Company - Success
import requests

url = "https://api.megaport.com/v2/employment"

response = requests.post(url)

print(response.json())
```

```javascript Invite a New User to an Existing Company - Success
const url = 'https://api.megaport.com/v2/employment';
const options = {method: 'POST'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Invite a New User to an Existing Company - Success
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.megaport.com/v2/employment"

	req, _ := http.NewRequest("POST", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Invite a New User to an Existing Company - Success
require 'uri'
require 'net/http'

url = URI("https://api.megaport.com/v2/employment")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
```

```java Invite a New User to an Existing Company - Success
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.megaport.com/v2/employment")
  .asString();
```

```php Invite a New User to an Existing Company - Success
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.megaport.com/v2/employment');

echo $response->getBody();
```

```csharp Invite a New User to an Existing Company - Success
using RestSharp;

var client = new RestClient("https://api.megaport.com/v2/employment");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift Invite a New User to an Existing Company - Success
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.megaport.com/v2/employment")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Invite (Add) a New User to an Existing Company

**Request**

```json
{
  "active": true,
  "email": "megaport.invalidfinanceuser@abcd.com",
  "firstName": "megaport",
  "lastName": "invalidfinanceuser",
  "phone": "+61 1233212334",
  "position": "Company Admin"
}
```

**Response**

```json
{
  "data": {
    "companyId": 54662,
    "employeeId": 54663,
    "employmentId": 49376
  },
  "message": "Employment 49376 Created -  employee 54663 created for Company 54662",
  "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy"
}
```

**SDK Code**

```python Invite (Add) a New User to an Existing Company
import requests

url = "https://api.megaport.com/v2/employment"

payload = {
    "active": True,
    "email": "megaport.invalidfinanceuser@abcd.com",
    "firstName": "megaport",
    "lastName": "invalidfinanceuser",
    "phone": "+61 1233212334",
    "position": "Company Admin"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Invite (Add) a New User to an Existing Company
const url = 'https://api.megaport.com/v2/employment';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"active":true,"email":"megaport.invalidfinanceuser@abcd.com","firstName":"megaport","lastName":"invalidfinanceuser","phone":"+61 1233212334","position":"Company Admin"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Invite (Add) a New User to an Existing Company
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.megaport.com/v2/employment"

	payload := strings.NewReader("{\n  \"active\": true,\n  \"email\": \"megaport.invalidfinanceuser@abcd.com\",\n  \"firstName\": \"megaport\",\n  \"lastName\": \"invalidfinanceuser\",\n  \"phone\": \"+61 1233212334\",\n  \"position\": \"Company Admin\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Invite (Add) a New User to an Existing Company
require 'uri'
require 'net/http'

url = URI("https://api.megaport.com/v2/employment")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"active\": true,\n  \"email\": \"megaport.invalidfinanceuser@abcd.com\",\n  \"firstName\": \"megaport\",\n  \"lastName\": \"invalidfinanceuser\",\n  \"phone\": \"+61 1233212334\",\n  \"position\": \"Company Admin\"\n}"

response = http.request(request)
puts response.read_body
```

```java Invite (Add) a New User to an Existing Company
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.megaport.com/v2/employment")
  .header("Content-Type", "application/json")
  .body("{\n  \"active\": true,\n  \"email\": \"megaport.invalidfinanceuser@abcd.com\",\n  \"firstName\": \"megaport\",\n  \"lastName\": \"invalidfinanceuser\",\n  \"phone\": \"+61 1233212334\",\n  \"position\": \"Company Admin\"\n}")
  .asString();
```

```php Invite (Add) a New User to an Existing Company
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.megaport.com/v2/employment', [
  'body' => '{
  "active": true,
  "email": "megaport.invalidfinanceuser@abcd.com",
  "firstName": "megaport",
  "lastName": "invalidfinanceuser",
  "phone": "+61 1233212334",
  "position": "Company Admin"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Invite (Add) a New User to an Existing Company
using RestSharp;

var client = new RestClient("https://api.megaport.com/v2/employment");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"active\": true,\n  \"email\": \"megaport.invalidfinanceuser@abcd.com\",\n  \"firstName\": \"megaport\",\n  \"lastName\": \"invalidfinanceuser\",\n  \"phone\": \"+61 1233212334\",\n  \"position\": \"Company Admin\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Invite (Add) a New User to an Existing Company
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "active": true,
  "email": "megaport.invalidfinanceuser@abcd.com",
  "firstName": "megaport",
  "lastName": "invalidfinanceuser",
  "phone": "+61 1233212334",
  "position": "Company Admin"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.megaport.com/v2/employment")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```