> Calendly developer docs. For page Markdown, append .md to any URL.
> Index: https://developer.calendly.com/llms.txt
> API catalog: https://developer.calendly.com/.well-known/api-catalog
> OpenAPI: https://developer.calendly.com/openapi/calendly-api.yaml
> OAuth authorization server: https://calendly.com/.well-known/oauth-authorization-server
> MCP protected resource: https://mcp.calendly.com/.well-known/oauth-protected-resource
> Scheduling MCP endpoint: https://mcp.calendly.com
> Docs search MCP: https://developer.calendly.com/_mcp/server

# Invite User to Organization

POST https://api.calendly.com/organizations/{uuid}/invitations
Content-Type: application/json

Invites a user to an organization.

> `organizations:write`

Reference: https://developer.calendly.com/api-docs/calendly-api/organizations/create-organization-invitation

## Authentication

- `Authorization` header (bearer token, required) — OAuth 2.0
- `Authorization` header (bearer token, required) — Personal Access Token

## Request

### Path parameters

- `uuid` (string, required) — The organization's unique identifier

### Body (application/json)

This endpoint expects an object.

- `email` (string, required) — The email of the user being invited

## Response

### 201

Created

- `resource` (OrganizationInvitation, required) — Organization Invitation object

## Errors

### 400 Bad Request Error

Bad Request

- `title` (string, required)
- `message` (string, required)
- `details` (list of ErrorResponseDetailsItem, optional)

### 401 Unauthorized Error

Cannot authenticate caller

- `title` (enum, required)
  - Allowed values: `Internal Server Error`
- `message` (enum, required)
  - Allowed values: `The server encountered an unexpected condition that prevented it from fulfilling the request.`
- `details` (list of ErrorResponseDetailsItem, optional)

### 403 Forbidden Error

Permission Denied or insufficient scope

- `Create-organization-invitationRequestForbiddenError`

### 404 Not Found Error

Requested resource not found

- `title` (enum, required)
  - Allowed values: `Internal Server Error`
- `message` (enum, required)
  - Allowed values: `The server encountered an unexpected condition that prevented it from fulfilling the request.`
- `details` (list of ErrorResponseDetailsItem, optional)

### 500 Internal Server Error

An error has occurred on the server

- `title` (enum, required)
  - Allowed values: `Internal Server Error`
- `message` (enum, required)
  - Allowed values: `The server encountered an unexpected condition that prevented it from fulfilling the request.`
- `details` (list of ErrorResponseDetailsItem, optional)

## Types

### OrganizationInvitation

Organization Invitation object

- `uri` (string, required) — Canonical reference (unique identifier) for the organization invitation
- `organization` (string, required) — Canonical reference (unique identifier) for the organization
- `email` (string, required) — The email address of the person who was invited to join the organization
- `status` (enum, required) — The status of the invitation ("pending", "accepted", or "declined")
  - Allowed values: `pending`, `accepted`, `declined`
- `created_at` (string, required) — The moment the invitation was created (e.g. “2020-01-02T03:04:05.678123Z")
- `updated_at` (string, required) — The moment the invitation was last updated (e.g. "2020-01-02T03:04:05.678123Z")
- `last_sent_at` (string, required, nullable) — The moment the invitation was last sent (e.g. "2020-01-02T03:04:05.678123Z")
- `user` (string, optional) — When the invitation is accepted, a reference to the user who accepted the invitation

### ErrorResponseDetailsItem

- `message` (string, required)
- `parameter` (string, optional)
- `code` (string, optional)

### OrganizationInvitationCreateError

Permission Denied

- `title` (enum, optional)
  - Allowed values: `Permission Denied`
- `message` (enum, optional)
  - Allowed values: `You already sent all the invitations you're allotted based upon the number of seats purchased with your account. Please purchase more seats to send more invitations.`, `You already sent all the invitations allotted to you with a trial account.`, `You do not have permission`, `You cannot perform this action for an organization with SCIM enabled.`

### InsufficientScopeError

Caller does not have required oauth scopes

- `title` (enum, required)
  - Allowed values: `Insufficient scope`
- `message` (enum, required)
  - Allowed values: `This operation requires the scopes listed in the 'required_scopes' array.`
- `required_scopes` (list of string, required)

## Examples

### Invite user request

**Request**

```json
{
  "email": "alice@example.com"
}
```

**Response**

```json
{
  "resource": {
    "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB",
    "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
    "email": "alice@example.com",
    "status": "pending",
    "created_at": "2020-01-01T20:30:00.000000Z",
    "updated_at": "2020-01-01T20:30:00.000000Z",
    "last_sent_at": "2020-01-01T20:30:00.123456Z"
  }
}
```

**SDK Code**

```python Invite user request
import requests

url = "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

payload = { "email": "alice@example.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Invite user request
const url = 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"alice@example.com"}'
};

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

```go Invite user request
package main

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

func main() {

	url := "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

	payload := strings.NewReader("{\n  \"email\": \"alice@example.com\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 user request
require 'uri'
require 'net/http'

url = URI("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"alice@example.com\"\n}"

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

```java Invite user request
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"alice@example.com\"\n}")
  .asString();
```

```php Invite user request
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations', [
  'body' => '{
  "email": "alice@example.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Invite user request
using RestSharp;

var client = new RestClient("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"alice@example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Invite user request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": "alice@example.com"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")! 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()
```

### Email is Invalid

**Request**

```json
{
  "email": "invalid_email@example"
}
```

**Response**

```json
{
  "resource": {
    "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB",
    "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
    "email": "alice@example.com",
    "status": "pending",
    "created_at": "2020-01-01T20:30:00.000000Z",
    "updated_at": "2020-01-01T20:30:00.000000Z",
    "last_sent_at": "2020-01-01T20:30:00.123456Z"
  }
}
```

**SDK Code**

```python Email is Invalid
import requests

url = "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

payload = { "email": "invalid_email@example" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Email is Invalid
const url = 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"invalid_email@example"}'
};

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

```go Email is Invalid
package main

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

func main() {

	url := "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

	payload := strings.NewReader("{\n  \"email\": \"invalid_email@example\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Email is Invalid
require 'uri'
require 'net/http'

url = URI("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"invalid_email@example\"\n}"

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

```java Email is Invalid
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"invalid_email@example\"\n}")
  .asString();
```

```php Email is Invalid
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations', [
  'body' => '{
  "email": "invalid_email@example"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Email is Invalid
using RestSharp;

var client = new RestClient("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"invalid_email@example\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Email is Invalid
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": "invalid_email@example"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")! 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()
```

### Email is Blank

**Request**

```json
{
  "email": ""
}
```

**Response**

```json
{
  "resource": {
    "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB",
    "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
    "email": "alice@example.com",
    "status": "pending",
    "created_at": "2020-01-01T20:30:00.000000Z",
    "updated_at": "2020-01-01T20:30:00.000000Z",
    "last_sent_at": "2020-01-01T20:30:00.123456Z"
  }
}
```

**SDK Code**

```python Email is Blank
import requests

url = "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

payload = { "email": "" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Email is Blank
const url = 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":""}'
};

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

```go Email is Blank
package main

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

func main() {

	url := "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

	payload := strings.NewReader("{\n  \"email\": \"\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Email is Blank
require 'uri'
require 'net/http'

url = URI("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"\"\n}"

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

```java Email is Blank
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"\"\n}")
  .asString();
```

```php Email is Blank
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations', [
  'body' => '{
  "email": ""
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Email is Blank
using RestSharp;

var client = new RestClient("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Email is Blank
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": ""] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")! 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()
```

### Email Exists in Organization

**Request**

```json
{
  "email": "email@example.com"
}
```

**Response**

```json
{
  "resource": {
    "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB",
    "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
    "email": "alice@example.com",
    "status": "pending",
    "created_at": "2020-01-01T20:30:00.000000Z",
    "updated_at": "2020-01-01T20:30:00.000000Z",
    "last_sent_at": "2020-01-01T20:30:00.123456Z"
  }
}
```

**SDK Code**

```python Email Exists in Organization
import requests

url = "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

payload = { "email": "email@example.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Email Exists in Organization
const url = 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"email@example.com"}'
};

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

```go Email Exists in Organization
package main

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

func main() {

	url := "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

	payload := strings.NewReader("{\n  \"email\": \"email@example.com\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Email Exists in Organization
require 'uri'
require 'net/http'

url = URI("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"email@example.com\"\n}"

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

```java Email Exists in Organization
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"email@example.com\"\n}")
  .asString();
```

```php Email Exists in Organization
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations', [
  'body' => '{
  "email": "email@example.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Email Exists in Organization
using RestSharp;

var client = new RestClient("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"email@example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Email Exists in Organization
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": "email@example.com"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")! 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()
```

### Invitation Already Exists

**Request**

```json
{
  "email": "email@example.com"
}
```

**Response**

```json
{
  "resource": {
    "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB",
    "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
    "email": "alice@example.com",
    "status": "pending",
    "created_at": "2020-01-01T20:30:00.000000Z",
    "updated_at": "2020-01-01T20:30:00.000000Z",
    "last_sent_at": "2020-01-01T20:30:00.123456Z"
  }
}
```

**SDK Code**

```python Invitation Already Exists
import requests

url = "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

payload = { "email": "email@example.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Invitation Already Exists
const url = 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"email@example.com"}'
};

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

```go Invitation Already Exists
package main

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

func main() {

	url := "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

	payload := strings.NewReader("{\n  \"email\": \"email@example.com\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Invitation Already Exists
require 'uri'
require 'net/http'

url = URI("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"email@example.com\"\n}"

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

```java Invitation Already Exists
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"email@example.com\"\n}")
  .asString();
```

```php Invitation Already Exists
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations', [
  'body' => '{
  "email": "email@example.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Invitation Already Exists
using RestSharp;

var client = new RestClient("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"email@example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Invitation Already Exists
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": "email@example.com"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")! 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()
```

### Race Condition

**Request**

```json
{
  "email": "alice@example.com"
}
```

**Response**

```json
{
  "resource": {
    "uri": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations/BBBBBBBBBBBBBBBB",
    "organization": "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA",
    "email": "alice@example.com",
    "status": "pending",
    "created_at": "2020-01-01T20:30:00.000000Z",
    "updated_at": "2020-01-01T20:30:00.000000Z",
    "last_sent_at": "2020-01-01T20:30:00.123456Z"
  }
}
```

**SDK Code**

```python Race Condition
import requests

url = "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

payload = { "email": "alice@example.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Race Condition
const url = 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"alice@example.com"}'
};

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

```go Race Condition
package main

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

func main() {

	url := "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations"

	payload := strings.NewReader("{\n  \"email\": \"alice@example.com\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Race Condition
require 'uri'
require 'net/http'

url = URI("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"email\": \"alice@example.com\"\n}"

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

```java Race Condition
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"alice@example.com\"\n}")
  .asString();
```

```php Race Condition
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations', [
  'body' => '{
  "email": "alice@example.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Race Condition
using RestSharp;

var client = new RestClient("https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"alice@example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Race Condition
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["email": "alice@example.com"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.calendly.com/organizations/AAAAAAAAAAAAAAAA/invitations")! 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()
```