# Create a new deal

`POST /api/deals`

Authentication (security requirement alternatives):

```json
[
  {
    "bearer": []
  }
]
```

- bearer: http (bearer), header JWT. Enter JWT token

Request body: application/json (required)

Type: object

- `select` (optional)
  Type: object

- `relations` (optional)
  Type: object

- `where` (required)
  Type: object

- `order` (optional)
  Type: object

- `withDeleted` (optional)
  Type: boolean

- `take` (optional)
  Type: number
  
  minimum: 0
  
  maximum: 100

- `skip` (optional)
  Type: number
  
  minimum: 0

Responses:

- 201: The deal has been successfully created.

Content type: application/json

Type: object

Schema: [Deal](https://sourcey-gauzy.pages.dev/api-reference/models/deal/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

- `title` (required)
  Type: string

- `probability` (required)
  Type: number

- `stageId` (required)
  Type: string

- `clientId` (optional)
  Type: string

- 400: Invalid request data.

- 401: Unauthorized

- 403: Forbidden

- 500: Internal server error.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/deals' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "select": {},
  "relations": {},
  "where": {},
  "order": {},
  "withDeleted": true,
  "take": 0,
  "skip": 0
}'
```

### JavaScript

```javascript
const body = `{
  "select": {},
  "relations": {},
  "where": {},
  "order": {},
  "withDeleted": true,
  "take": 0,
  "skip": 0
}`;

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

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

### Python

```python
import requests

body = '''{
  "select": {},
  "relations": {},
  "where": {},
  "order": {},
  "withDeleted": true,
  "take": 0,
  "skip": 0
}'''

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