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

# Create Invite

POST https://api.onepin.ai/api/v1/workspaces/{ws_id}/invites
Content-Type: application/json

Invite a user to the workspace by email. Admin only.

Creates a pending invite and sends an invitation email to the specified
address. The invitee does not need to have an existing account — they can
sign up after receiving the invite. The invite includes a role
(`admin`, `editor`, or `viewer`) that the invitee will receive upon
accepting.

Invites expire after 14 days. Only one pending invite per email address
per workspace is allowed at a time; re-inviting the same address while a
pending invite exists returns 409. Inviting an address that already
belongs to an active member also returns 409.

The invitee's role can be updated before acceptance via
`PATCH /workspaces/{ws_id}/invites/{invite_id}`, or the invite can be
cancelled via `DELETE /workspaces/{ws_id}/invites/{invite_id}`.

Reference: https://onepin.ai/docs/reference/api-reference/workspace-members/create-invite-api-v-1-workspaces-ws-id-invites-post

## Authentication

- `Authorization` header (bearer token, required) — Clerk JWT token

## Servers

- `https://api.onepin.ai` (prod, default)
- `https://dev-api.onepin.ai` (dev)

## Request

### Path parameters

- `ws_id` (string, required)

### Body (application/json)

This endpoint expects a WorkspaceInviteCreate.

- `email` (string, required) — Email address to invite. Normalized to lowercase. Returns 409 if this address is already an active member or has a pending invite.
- `role` (enum, required) — Role to grant when the invite is accepted: `admin`, `editor`, or `viewer`.
  - Allowed values: `admin`, `editor`, `viewer`

## Response

### 201

Successful Response

- `data` (WorkspaceInviteOut, required)
- `meta` (Meta, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### WorkspaceInviteOut

- `id` (string, required) — Unique invite ID.
- `email` (string, required) — Email address the invite was sent to.
- `role` (string, required) — Role the invitee will receive on acceptance: `admin`, `editor`, or `viewer`.
- `status` (string, required) — Current invite status: `pending`, `accepted`, `revoked`, or `expired`.
- `expires_at` (datetime, required) — When the invite expires (UTC). Invites have a 14-day TTL from creation.
- `invited_by` (string, required) — User ID of the admin who created the invite.
- `created_at` (datetime, required) — When the invite was created (UTC).

### Meta

- `request_id` (string, required)
- `timestamp` (datetime, required)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "email": "jane.doe@example.com",
  "role": "admin"
}
```

**Response**

```json
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "email": "jane.doe@example.com",
    "role": "admin",
    "status": "pending",
    "expires_at": "2024-07-01T09:30:00Z",
    "invited_by": "1c9d4f8e-2b7a-4f3e-9a1d-5f6e7b8c9d0a",
    "created_at": "2024-06-17T09:30:00Z"
  },
  "meta": {
    "request_id": "req_7f8e9d6c5b4a3e2f1d0c",
    "timestamp": "2024-06-17T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.onepin.ai/api/v1/workspaces/ws_id/invites"

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

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

print(response.json())
```

```javascript
const url = 'https://api.onepin.ai/api/v1/workspaces/ws_id/invites';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"jane.doe@example.com","role":"admin"}'
};

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

```go
package main

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

func main() {

	url := "https://api.onepin.ai/api/v1/workspaces/ws_id/invites"

	payload := strings.NewReader("{\n  \"email\": \"jane.doe@example.com\",\n  \"role\": \"admin\"\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
require 'uri'
require 'net/http'

url = URI("https://api.onepin.ai/api/v1/workspaces/ws_id/invites")

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\": \"jane.doe@example.com\",\n  \"role\": \"admin\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.onepin.ai/api/v1/workspaces/ws_id/invites")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"jane.doe@example.com\",\n  \"role\": \"admin\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.onepin.ai/api/v1/workspaces/ws_id/invites', [
  'body' => '{
  "email": "jane.doe@example.com",
  "role": "admin"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.onepin.ai/api/v1/workspaces/ws_id/invites");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"jane.doe@example.com\",\n  \"role\": \"admin\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.onepin.ai/api/v1/workspaces/ws_id/invites")! 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()
```