---
title: "createInvite"
---

> Documentation Index
> Fetch the complete documentation index at: https://agenthold.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# createInvite

Path: agenthold API › invites

`POST /workspaces/{workspaceId}/invites`

URL: `/api/v1/workspaces/{workspaceId}/invites`

## Authentication

Requires one of the following:

- `session`, apiKey, in cookie
- `token`, http bearer, header `Authorization`

## Path parameters

- `workspaceId` (`createInvite.path.workspaceId`; string, required)

## Request body

_Required._

- `role` (`createInvite.role`; string, required)
  - one of `"admin"`, `"member"`
- `email` (`createInvite.email`; string, optional) — If set, only a user with this email can accept.
- `expiresInHours` (`createInvite.expiresInHours`; integer, optional) — Defaults to 168 (7 days).
  - maximum: `720` · minimum: `1`

## Example request

```json
{
  "role": "admin",
  "email": "string",
  "expiresInHours": 1
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/api/v1/workspaces/<workspaceId>/invites' \
  --header 'Content-Type: application/json' \
  --cookie 'agenthold_session=<agenthold_session>' \
  --data '
{
  "role": "admin",
  "email": "string",
  "expiresInHours": 1
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/workspaces/<workspaceId>/invites';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    cookie: 'agenthold_session=<agenthold_session>'
  },
  body: JSON.stringify({role: 'admin', email: 'string', expiresInHours: 1})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/api/v1/workspaces/<workspaceId>/invites"

payload = {
    "role": "admin",
    "email": "string",
    "expiresInHours": 1
}
headers = {
    "cookie": "agenthold_session=<agenthold_session>",
    "Content-Type": "application/json"
}

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

print(response.text)
```

## Responses

### 201

Created. The token is only returned once.

#### Example

```json
{
  "id": "string",
  "role": "admin",
  "email": "string",
  "createdBy": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "expiresAt": "2019-08-24T14:15:22Z",
  "token": "string",
  "url": "string"
}
```

- `id` (`createInvite.response.201.id`; string, required)
- `role` (`createInvite.response.201.role`; string, required)
  - one of `"admin"`, `"member"`
- `email` (`createInvite.response.201.email`; string, required)
- `createdBy` (`createInvite.response.201.createdBy`; string, required)
- `createdAt` (`createInvite.response.201.createdAt`; string, required)
  - format: `date-time`
- `expiresAt` (`createInvite.response.201.expiresAt`; string, required)
  - format: `date-time`
- `token` (`createInvite.response.201.token`; string, required)
- `url` (`createInvite.response.201.url`; string, required) — Link to share with the invitee.

### 400

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createInvite.response.400.error`; string, required)

### 403

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createInvite.response.403.error`; string, required)

### 404

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createInvite.response.404.error`; string, required)


Source: https://agenthold.dev/api/create-invite/index.md
