# Create a payroll run

`POST /api/payroll-run`

Authentication: no security requirement declared for this operation.

Request body: application/json (required)

Type: object

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

- `tenant` (optional)
  Type: object

- `tenantId` (optional)
  Type: string

- `organization` (required)
  Type: object

- `organizationId` (required)
  Type: string

- `sentTo` (optional)
  Type: string

- `periodStart` (required)
  Type: string, date-time

- `periodEnd` (required)
  Type: string, date-time

- `payDate` (required)
  Type: string, date-time

- `frequency` (required)
  Type: string
  
  enum: ["WEEKLY","BI_WEEKLY","SEMI_MONTHLY","MONTHLY","QUARTERLY","ANNUALLY"]

- `currency` (required)
  Type: string
  
  minLength: 3
  
  maxLength: 3

- `notes` (optional)
  Type: string
  
  maxLength: 500

Responses:

- 201: The payroll run has been created.

- 400: Invalid input, check the response body for details

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/payroll-run' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "periodStart": "2024-01-15T09:30:00Z",
  "periodEnd": "2024-01-15T09:30:00Z",
  "payDate": "2024-01-15T09:30:00Z",
  "frequency": "WEEKLY",
  "currency": "string",
  "notes": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "periodStart": "2024-01-15T09:30:00Z",
  "periodEnd": "2024-01-15T09:30:00Z",
  "payDate": "2024-01-15T09:30:00Z",
  "frequency": "WEEKLY",
  "currency": "string",
  "notes": "string"
}`;

const response = await fetch('http://localhost:3000/api/payroll-run', {
  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",
  "periodStart": "2024-01-15T09:30:00Z",
  "periodEnd": "2024-01-15T09:30:00Z",
  "payDate": "2024-01-15T09:30:00Z",
  "frequency": "WEEKLY",
  "currency": "string",
  "notes": "string"
}'''

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