API Documentation
Programmatic access to your CodeVault snippets.
Introduction
The CodeVault REST API lets you read, create, update, and delete snippets programmatically. All responses are JSON. All requests that modify data require authentication via an API key.
Base URL:
https://codevault-production-86f2.up.railway.app/api/v1
Authentication
Authenticate by including your API key in the Authorization header of every request.
You can generate or regenerate your API key from your
Settings page.
Header format
Authorization: Bearer YOUR_API_KEY
Example with curl
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://codevault-production-86f2.up.railway.app/api/v1/snippets
Rate Limits
The API is rate limited to 100 requests per hour per API key.
When the limit is exceeded, the API returns HTTP 429 Too Many Requests.
{
"error": "Rate limit exceeded. Max 100 requests per hour."
}
Endpoints
Returns a paginated list of snippets belonging to the authenticated user.
Request headers
Authorization: Bearer YOUR_API_KEY
Query parameters
page integer Page number (default: 1)
limit integer Results per page, max 100 (default: 20)
language string Filter by programming language
tag string Filter by tag
Example response
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Debounce function",
"description": "Limits how often a function can fire.",
"language": "javascript",
"tags": "utils,performance",
"is_public": true,
"view_count": 42,
"star_count": 7,
"created_at": "2026-03-10T14:22:00Z",
"updated_at": "2026-03-10T14:22:00Z"
}
],
"meta": {
"total": 1,
"page": 1,
"limit": 20
}
}
Returns a single snippet by ID. You can only retrieve snippets you own, or public snippets.
Request headers
Authorization: Bearer YOUR_API_KEY
Example response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Debounce function",
"description": "Limits how often a function can fire.",
"code": "function debounce(fn, delay) {\n let t;\n return (...args) => {\n clearTimeout(t);\n t = setTimeout(() => fn(...args), delay);\n };\n}",
"language": "javascript",
"tags": "utils,performance",
"is_public": true,
"view_count": 42,
"star_count": 7,
"created_at": "2026-03-10T14:22:00Z",
"updated_at": "2026-03-10T14:22:00Z"
}
Error response
{ "error": "Snippet not found" }
Creates a new snippet owned by the authenticated user.
Request headers
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Request body
{
"title": "string (required, max 255 chars)",
"code": "string (required)",
"language": "string (required, e.g. javascript)",
"description": "string (optional)",
"tags": "string (optional, comma-separated)",
"is_public": "boolean (optional, default false)"
}
Example response
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"title": "My new snippet",
"language": "python",
"created_at": "2026-03-17T09:00:00Z"
}
Error response
{ "error": "title and code are required" }
Updates an existing snippet. You may only update snippets you own. Send only the fields you want to change.
Request headers
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Request body
{
"title": "string",
"code": "string",
"language": "string",
"description": "string",
"tags": "string",
"is_public": "boolean"
}
Example response
{ "success": true, "id": "550e8400-e29b-41d4-a716-446655440000" }
Permanently deletes a snippet and all associated stars. You may only delete snippets you own.
Request headers
Authorization: Bearer YOUR_API_KEY
Example response
{ "success": true }
Error response
{ "error": "Forbidden" }