◫ Docs → API Reference

API Reference

Every collection you create in CodeNx gets a full REST and GraphQL API automatically. No code required — the endpoints are live the moment you save your schema.

Authentication

All API endpoints require a Bearer token or API key header.

# Bearer token (from login response)
Authorization: Bearer <access_token>

# API key (created in admin panel)
X-API-Key: cnx_live_xxxxxxxxxxxxxxxxxxxx

Endpoints

Replace {collection} with your collection slug (e.g. products, orders).

Method
Path
Description
GET
/api/v1/{collection}
List all records. Supports ?filter[], ?sort, ?page, ?limit, ?fields.
POST
/api/v1/{collection}
Create a new record. Triggers AI embedding pipeline on text fields.
GET
/api/v1/{collection}/:id
Fetch a single record by ID with all fields.
PATCH
/api/v1/{collection}/:id
Partial update. Only provided fields are changed. Re-embeds on text changes.
DELETE
/api/v1/{collection}/:id
Soft delete. Record is removed from API but retained in audit log for 30 days.
POST
/api/v1/{collection}/search
Semantic AI search. Pass a natural language query, get ranked results with similarity scores.
GET
/api/v1/{collection}/:id/similar
Similarity recommendations. Returns records most similar to the given record.
POST
/api/v1/{collection}/bulk
Bulk create or update up to 500 records in a single request.
GET
/api/v1/{collection}/export
Export collection as CSV or JSON. Respects active filters.

Filtering

Pass filter parameters as query strings using bracket notation.

# Filter by exact value
GET /api/v1/products?filter[status]=active

# Filter with operator
GET /api/v1/products?filter[price][gte]=100&filter[price][lte]=500

# Supported operators: eq, ne, gt, gte, lt, lte, in, nin, like, null

Sorting

# Sort ascending
GET /api/v1/products?sort=name

# Sort descending (prefix with -)
GET /api/v1/products?sort=-created_at

# Multi-field sort
GET /api/v1/products?sort=-created_at,name

Pagination

GET /api/v1/products?page=2&limit=20

# Response includes meta object
{
  "data": [...],
  "meta": { "total": 1200, "page": 2, "limit": 20, "pages": 60 }
}

POST to the /search endpoint with a natural language query. Returns records ranked by similarity score.

POST /api/v1/products/search

{
  "query": "handcrafted jewellery under ₹2000",
  "limit": 10,
  "filter": { "status": "active" }
}

# Response includes similarity score per result

Error Responses

400
Bad Request
Invalid input — check your request body against the Zod schema.
401
Unauthorized
Missing or expired token. Refresh your access token and retry.
403
Forbidden
Valid token but insufficient permissions. Check the permission slug.
404
Not Found
Record does not exist or belongs to a different tenant.
429
Rate Limited
Too many requests. Backed off with exponential retry.
500
Server Error
Unexpected error. Logged automatically — contact support if persistent.