Skip to main content

API Overview

The Linktor API is a RESTful API that provides programmatic access to all Linktor features. Use the API to send messages, manage conversations, configure channels, and build integrations.

Base URL​

All API requests should be made to:

https://api.linktor.io/v1

For self-hosted installations, replace with your own domain:

https://your-domain.com/api/v1

Authentication​

The Linktor API uses Bearer token authentication. Include your API key in the Authorization header of every request:

curl https://api.linktor.io/v1/conversations \
-H "Authorization: Bearer YOUR_API_KEY"

You can generate API keys in the Linktor dashboard under Settings > API Keys.

Authentication Methods​

MethodUse Case
API KeyServer-to-server integrations
JWT TokenUser sessions and frontend applications
OAuth 2.0Third-party application integrations

See Authentication for detailed documentation on authentication endpoints.

Request Format​

Headers​

All requests should include the following headers:

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonYes (for POST/PUT/PATCH)
Acceptapplication/jsonRecommended
X-Request-IDUUIDOptional (for tracing)

Request Body​

For POST, PUT, and PATCH requests, send data as JSON in the request body:

curl -X POST https://api.linktor.io/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channelId": "ch_abc123",
"to": "+5511999999999",
"content": {
"type": "text",
"text": "Hello from Linktor!"
}
}'

Response Format​

All responses are returned in JSON format with a consistent structure.

Successful Response​

Single resource:

{
"data": {
"id": "msg_abc123",
"type": "message",
"attributes": {
"channelId": "ch_xyz789",
"content": {
"type": "text",
"text": "Hello from Linktor!"
},
"status": "delivered",
"createdAt": "2024-01-15T10:30:00Z"
}
},
"meta": {
"requestId": "req_def456"
}
}

Collection:

{
"data": [
{
"id": "msg_abc123",
"type": "message",
"attributes": { ... }
},
{
"id": "msg_def456",
"type": "message",
"attributes": { ... }
}
],
"meta": {
"requestId": "req_ghi789",
"pagination": {
"page": 1,
"perPage": 20,
"totalPages": 5,
"totalCount": 100
}
}
}

Error Response​

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": [
{
"field": "to",
"message": "Phone number must be in E.164 format"
}
]
},
"meta": {
"requestId": "req_xyz789"
}
}

Pagination​

List endpoints support pagination using the following query parameters:

ParameterTypeDefaultDescription
pageinteger1Page number (1-indexed)
perPageinteger20Items per page (max: 100)
sortBystringcreatedAtField to sort by
sortOrderstringdescSort order (asc or desc)

Example​

curl "https://api.linktor.io/v1/conversations?page=2&perPage=50&sortBy=updatedAt&sortOrder=desc" \
-H "Authorization: Bearer YOUR_API_KEY"

Pagination Response​

{
"data": [...],
"meta": {
"pagination": {
"page": 2,
"perPage": 50,
"totalPages": 10,
"totalCount": 500,
"hasNextPage": true,
"hasPrevPage": true
}
}
}

Cursor-Based Pagination​

For real-time data streams, some endpoints support cursor-based pagination:

ParameterTypeDescription
cursorstringCursor from previous response
limitintegerNumber of items to return (max: 100)
curl "https://api.linktor.io/v1/messages?cursor=eyJpZCI6Im1zZ18xMjM0NTYifQ&limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"

Filtering​

Most list endpoints support filtering via query parameters:

# Filter conversations by status
curl "https://api.linktor.io/v1/conversations?status=open" \
-H "Authorization: Bearer YOUR_API_KEY"

# Filter messages by date range
curl "https://api.linktor.io/v1/messages?startDate=2024-01-01&endDate=2024-01-31" \
-H "Authorization: Bearer YOUR_API_KEY"

# Multiple filters
curl "https://api.linktor.io/v1/conversations?status=open&channelId=ch_abc123&assigneeId=user_xyz" \
-H "Authorization: Bearer YOUR_API_KEY"

Error Codes​

The API uses standard HTTP status codes and custom error codes:

HTTP Status Codes​

CodeDescription
200Success
201Created
204No Content (successful delete)
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource doesn't exist
409Conflict - Resource already exists
422Unprocessable Entity - Validation failed
429Too Many Requests - Rate limit exceeded
500Internal Server Error
503Service Unavailable

Error Codes​

CodeDescription
AUTHENTICATION_REQUIREDNo API key provided
INVALID_API_KEYAPI key is invalid or expired
INSUFFICIENT_PERMISSIONSAPI key lacks required permissions
VALIDATION_ERRORRequest validation failed
RESOURCE_NOT_FOUNDRequested resource doesn't exist
RESOURCE_ALREADY_EXISTSResource with same identifier exists
RATE_LIMIT_EXCEEDEDToo many requests
CHANNEL_ERRORError communicating with channel provider
INTERNAL_ERRORUnexpected server error

Rate Limiting​

The API enforces rate limits to ensure fair usage:

TierRequests/minuteRequests/day
Free601,000
Starter30010,000
Pro1,000100,000
EnterpriseCustomCustom

Rate limit headers are included in every response:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1705312800

When rate limited, you'll receive a 429 response:

{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please retry after 60 seconds.",
"retryAfter": 60
}
}

Idempotency​

For POST requests, you can provide an Idempotency-Key header to ensure the request is processed only once:

curl -X POST https://api.linktor.io/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: unique-request-id-123" \
-d '{
"channelId": "ch_abc123",
"to": "+5511999999999",
"content": {
"type": "text",
"text": "Hello!"
}
}'

Idempotency keys are stored for 24 hours. Replaying a request with the same key will return the original response.

Versioning​

The API is versioned via the URL path. The current version is v1:

https://api.linktor.io/v1/...

When we introduce breaking changes, we'll release a new version. Previous versions remain available for a deprecation period.

SDKs​

Instead of making raw HTTP requests, consider using our official SDKs:

Next Steps​