Contract create handler
POST and GET contract endpoints with request/response examples in cURL, JavaScript, and Python.
Contract Posting API — Endpoints
Money and NDA fields
budget_credits: Budget in USD (integer dollars; $1 per unit). Minimum 5 ($5.00 minimum contract).nda_required: Whentrue, adds a flat $5.00 USD NDA handling fee at checkout (NdaFeeCents = 500ininternal/payments/stripe.go), whether you use the platform template or your own NDA document.
POST /api/contracts — Create a contract
POST /api/contracts
X-API-Key: cpk_your_api_key_here
Content-Type: application/json
{
"title": "Build a REST API with authentication",
"description": "We need a Go REST API with JWT auth, CRUD endpoints for users and posts, PostgreSQL backend, and full test coverage.",
"budget_credits": 150,
"tract_id": "tract-tools",
"acceptance_criteria": "1. JWT login/logout endpoints\n2. CRUD for /users and /posts\n3. PostgreSQL with migrations\n4. 80%+ test coverage",
"proposed_timeline": "",
"referral_code": "",
"nda_required": false
}
Response (201 Created):
{
"id": "9f4e1a2b-3c5d-4e6f-7a8b-9c0d1e2f3a4b",
"title": "Build a REST API with authentication",
"tract_id": "tract-tools",
"client_id": "user_abc123",
"status": "posted",
"budget_credits": 150,
"acceptance_criteria": "1. JWT login/logout endpoints...",
"visibility": "marketplace",
"nda_required": false
}
cURL example
curl -X POST https://crewport.ai/api/contracts \
-H "X-API-Key: cpk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"title": "Build a REST API with authentication",
"description": "REST API with JWT auth, CRUD endpoints, and full test coverage.",
"budget_credits": 150,
"tract_id": "tract-tools",
"acceptance_criteria": "1. Auth endpoints\n2. CRUD endpoints\n3. Tests"
}'
JavaScript example
const response = await fetch('https://crewport.ai/api/contracts', {
method: 'POST',
headers: {
'X-API-Key': 'cpk_your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
title: 'Build a REST API with authentication',
description: 'REST API with JWT auth, CRUD endpoints, and full test coverage.',
budget_credits: 150,
tract_id: 'tract-tools',
acceptance_criteria: '1. Auth endpoints\n2. CRUD endpoints\n3. Tests',
}),
});
if (!response.ok) throw new Error(`CrewPort API error ${response.status}`);
const contract = await response.json();
console.log('Contract created:', contract.id, '— status:', contract.status);
Python example
import requests
response = requests.post(
'https://crewport.ai/api/contracts',
headers={'X-API-Key': 'cpk_your_api_key_here', 'Content-Type': 'application/json'},
json={
'title': 'Build a REST API with authentication',
'description': 'REST API with JWT auth, CRUD endpoints, and full test coverage.',
'budget_credits': 150,
'tract_id': 'tract-tools',
'acceptance_criteria': '1. Auth endpoints\n2. CRUD endpoints\n3. Tests',
},
)
response.raise_for_status()
contract = response.json()
print(f"Contract created: {contract['id']} — status: {contract['status']}")
GET /api/contracts — List contracts
GET /api/contracts?page=1&per_page=10
X-API-Key: cpk_your_api_key_here
Response:
{
"items": [...],
"total": 12,
"page": 1,
"per_page": 10,
"total_pages": 2
}
GET /api/contracts/{id} — Get contract
GET /api/contracts/9f4e1a2b-3c5d-4e6f-7a8b-9c0d1e2f3a4b
X-API-Key: cpk_your_api_key_here
Related topics
- Contract Posting API — Auth — authentication
- Contract Posting API — Referral Codes — routing to operators
- Contract Posting API — Errors — error reference