# Create email invites

`POST /api/invite/emails`

Authentication: no security requirement declared for this operation.

Request body: application/json (required)

Type: object

Schema: [CreateInviteDTO](https://sourcey-gauzy.pages.dev/api-reference/models/createinvitedto/index.md)

- `tenant` (optional)
  Type: object

- `tenantId` (optional)
  Type: string

- `organization` (required)
  Type: object

- `organizationId` (required)
  Type: string

- `sentTo` (optional)
  Type: string

- `emailIds` (required)
  Type: array
  
  Items:
    Type: string

- `teamIds` (optional)
  Type: array
  
  Items:
    Type: string

- `inviteType` (required)
  Type: string
  
  enum: ["USER","EMPLOYEE","CANDIDATE","TEAM"]

- `startedWorkOn` (optional)
  Type: string, date-time

- `invitationExpirationPeriod` (optional)
  Type: string
  
  enum: [1,7,14,30,"Never"]

- `fullName` (optional)
  Type: string

- `callbackUrl` (optional)
  Type: string

- `roleId` (required)
  Type: string

- `role` (required)
  Type: object
  
  Role reference: an object with the role `id` (UUID).

Responses:

- 201: The record has been successfully created.

Content type: application/json

Type: object

Schema: [Invite](https://sourcey-gauzy.pages.dev/api-reference/models/invite/index.md)

- `deletedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `createdAt` (optional)
  Type: string, date-time
  
  The creation timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `updatedAt` (optional)
  Type: string, date-time
  
  The last update timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `id` (optional)
  Type: string

- `isActive` (optional)
  Type: boolean
  
  default: true

- `isArchived` (optional)
  Type: boolean
  
  default: false

- `archivedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `tenantId` (optional)
  Type: string

- `organizationId` (optional)
  Type: string

- `token` (required)
  Type: string

- `email` (required)
  Type: string

- `fullName` (optional)
  Type: string

- `status` (required)
  Type: string
  
  enum: ["INVITED","ACCEPTED","EXPIRED","REJECTED"]

- `expireDate` (optional)
  Type: string, date-time

- `actionDate` (optional)
  Type: string, date-time

- `role` (optional)
  Reference: [Role](https://sourcey-gauzy.pages.dev/api-reference/models/role/index.md); Type: object

- `roleId` (optional)
  Type: string

- `userId` (optional)
  Type: string

- 400: Invalid input, The response body may contain clues as to what went wrong

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/invite/emails' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "emailIds": [
    "string"
  ],
  "teamIds": [
    "string"
  ],
  "inviteType": "USER",
  "startedWorkOn": "2024-01-15T09:30:00Z",
  "invitationExpirationPeriod": 1,
  "fullName": "string",
  "callbackUrl": "string",
  "roleId": "string",
  "role": {}
}'
```

### JavaScript

```javascript
const body = `{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "emailIds": [
    "string"
  ],
  "teamIds": [
    "string"
  ],
  "inviteType": "USER",
  "startedWorkOn": "2024-01-15T09:30:00Z",
  "invitationExpirationPeriod": 1,
  "fullName": "string",
  "callbackUrl": "string",
  "roleId": "string",
  "role": {}
}`;

const response = await fetch('http://localhost:3000/api/invite/emails', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "emailIds": [
    "string"
  ],
  "teamIds": [
    "string"
  ],
  "inviteType": "USER",
  "startedWorkOn": "2024-01-15T09:30:00Z",
  "invitationExpirationPeriod": 1,
  "fullName": "string",
  "callbackUrl": "string",
  "roleId": "string",
  "role": {}
}'''

response = requests.post(
    'http://localhost:3000/api/invite/emails',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
