Contexts API
Create, read, update, and delete context files programmatically.
The Context Object
A context file contains structured information that can be provided to AI assistants.
Context Object
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "My AI Assistant",
"slug": "my-ai-assistant",
"description": "Context for my personal AI assistant",
"content": {
"basics": {
"name": "Assistant Name",
"role": "Personal Assistant"
},
"preferences": { ... },
"knowledge": [ ... ]
},
"is_public": false,
"version": "1.0.0",
"version_number": 1,
"view_count": 42,
"copy_count": 12,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T14:45:00Z"
}GET
/v1/contextsList Contexts
Returns a paginated list of all context files belonging to the authenticated user.
Parameters
| Name | Type | Description |
|---|---|---|
limit | integer | Number of results per page (1-100, default: 50) |
offset | integer | Number of results to skip (default: 0) |
sort | string | Sort field: updated_at, created_at, name, view_count, copy_count |
order | string | Sort order: asc or desc (default: desc) |
curl https://api.contextfile.ai/v1/contexts \
-H "Authorization: Bearer YOUR_API_KEY"POST
/v1/contextsCreate Context
Creates a new context file.
Parameters
| Name | Type | Description |
|---|---|---|
nameRequired | string | The name of the context (max 100 characters) |
slugRequired | string | URL-friendly identifier (lowercase, hyphens only) |
description | string | Brief description (max 500 characters) |
content | object | The context content as a JSON object |
is_public | boolean | Whether the context is publicly accessible (default: true) |
curl https://api.contextfile.ai/v1/contexts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My AI Assistant",
"slug": "my-ai-assistant",
"description": "Context for my personal AI assistant",
"content": {
"basics": {
"name": "Claude",
"role": "Personal Assistant"
}
},
"is_public": false
}'GET
/v1/contexts/:idGet Context
Retrieves a specific context file by ID.
Parameters
| Name | Type | Description |
|---|---|---|
idRequired | string | The context ID (path parameter) |
curl https://api.contextfile.ai/v1/contexts/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer YOUR_API_KEY"PATCH
/v1/contexts/:idUpdate Context
Updates an existing context file. Only include fields you want to change.
Parameters
| Name | Type | Description |
|---|---|---|
idRequired | string | The context ID (path parameter) |
name | string | New name for the context |
description | string | New description |
content | object | New content (replaces existing) |
is_public | boolean | Update visibility |
curl -X PATCH https://api.contextfile.ai/v1/contexts/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": {
"basics": {
"name": "Claude",
"role": "Expert Coder"
}
}
}'DELETE
/v1/contexts/:idDelete Context
Deletes a context file. This is a soft delete - the context can be restored within 30 days.
Parameters
| Name | Type | Description |
|---|---|---|
idRequired | string | The context ID (path parameter) |
curl -X DELETE https://api.contextfile.ai/v1/contexts/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer YOUR_API_KEY"Error Responses
400Bad Request
Invalid parameters or missing required fields.
404Not Found
Context file doesn't exist or you don't have access.
409Conflict
A context with that slug already exists.
413Payload Too Large
Request body exceeds maximum size (500KB).