# Add New Contract

`POST /api/contracts`



- **Group:** Contracts
- **Since:** v0.3.0
- **Authentication:** `authtoken` header, created under Setup > API > API Management
- **HTML version:** /apiguide/contracts/post-contract/

## Headers

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `authtoken` | String | **required** | Authentication token, generated from admin area |

## Parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `subject` | String | **required** | Mandatory. Contract subject |
| `datestart` | Date | **required** | Mandatory. Contract start date |
| `client` | Number | **required** | Mandatory. Customer ID |
| `dateend` | Date | **required** | Optional. Contract end date |
| `contract_type` | Number | **required** | Optional. Contract type |
| `contract_value` | Number | **required** | Optional. Contract value |
| `description` | String | **required** | Optional. Contract description |
| `content` | String | **required** | Optional. Contract content |

## Example request

```bash
curl -X POST "https://yoursite.com/api/contracts" \
  -H "authtoken: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "subject": "...", "datestart": "...", "client": "...", "dateend": "...", "contract_type": "...", "contract_value": "...", "description": "...", "content": "..." }'
```

## Success response

### Success-Response:

```json
HTTP/1.1 200 OK
{
  "status": true,
  "message": "Contract Added Successfully"
}
```

## Error responses

### Error-Response:

```json
HTTP/1.1 404 Not Found
{
  "status": false,
  "message": "Contract ID Exists"
}
```

### Error-Response:

```json
  HTTP/1.1 404 Not Found
   {
	    "status": false,
	    "error": {
	        "newitems[]": "The Start date field is required"
	    },
	    "message": "<p>The Start date field is required</p>\n"
	}
```

### Error-Response:

```json
  HTTP/1.1 404 Not Found
   {
	    "status": false,
	    "error": {
	        "subtotal": "The Subject field is required"
	    },
	    "message": "<p>The Subject field is required</p>\n"
	}
```

### Error-Response:

```json
  HTTP/1.1 404 Not Found
   {
	    "status": false,
	    "error": {
	        "total": "The Customer ID is required"
	    },
	    "message": "<p>The Customer ID is required</p>\n"
	}
```

---

Perfex CRM REST API by Themesic Interactive. Full reference: /apiguide/
