Contents
API v2 reference
Contract version 2.0.0-alpha.1
The API v2 lets you automate everything you do in the customer portal: sites, custom domains, certificates, purges, analytics, your team and your account. It is a JSON API over HTTPS described by an OpenAPI 3.1 contract, and this reference is generated from that contract.
Base URL
Send every request over HTTPS to the API host. All paths start with /api/v2.
https://api.cdnify.lat/api/v2Authentication
Integrations authenticate with an API token, sent as a bearer token in the Authorization header. Tokens start with cdnx_.
curl 'https://api.cdnify.lat/api/v2/organization' \
-H "Authorization: Bearer $CDNIFY_API_TOKEN"Create tokens in the customer portal, on the API tokens page. Creating a token needs a verified e-mail address and a recent sign-in. The secret is shown only once: keep it in a secret manager, never in source code. A token can have an expiry date, and revoking it takes effect at once.
Some operations belong to the portal itself, such as signing in or managing tokens, and accept only a signed-in session; they are marked as such. Keys of the legacy API v1 do not work on the API v2.
Examples read credentials from environment variables: replace them with your own values, never paste a secret into a shared script. CDNIFY_API_TOKEN
Permissions and scopes
Each operation shows the permission it needs, such as sites.read or cache.purge. A token carries the scopes chosen when it was created: single permissions, every permission of a resource (sites.*) or every permission (*). Give each token only the scopes it needs.
A request without the needed permission answers 403 with the code insufficient_scope or forbidden.
Requests and responses
Request bodies are JSON, sent with Content-Type: application/json. Unknown fields are rejected, so a typo never changes what a request does. Dates are RFC 3339 timestamps.
Every response carries an X-Request-Id header. Quote it when you contact support.
Errors
Errors use the problem details format of RFC 9457 (application/problem+json). The code field is a stable identifier: build your integration on it, not on title or detail, which are translated according to Accept-Language (English or Spanish).
The type field is the address of the page that explains the code. Validation errors (422) list every invalid field in errors, and every problem includes its request_id.
{
"type": "https://www.cdnify.lat/docs/errors/validation_failed",
"title": "Validation failed",
"status": 422,
"code": "validation_failed",
"request_id": "req_01EXAMPLE00000000000000000",
"errors": [
{
"field": "origin.host",
"code": "destination_blocked",
"message": "…"
}
]
}Pagination
Lists that can grow are paginated with an opaque cursor. Pass limit (1 to 200, 50 by default) and, for the next page, the value of pagination.next_cursor as cursor. pagination.has_more tells whether there are more pages.
curl 'https://api.cdnify.lat/api/v2/sites?limit=50&cursor=NEXT_CURSOR' \
-H "Authorization: Bearer $CDNIFY_API_TOKEN"Do not build or store cursors: an invalid or expired cursor answers 400 with the code cursor_expired, and you start again from the first page.
Idempotency and retries
Operations that create something accept an Idempotency-Key header with a unique value of up to 255 characters, such as a UUID. When a request is retried with the same key and the same body, the API returns the original answer with Idempotency-Replayed: true instead of doing the work twice.
The same key with a different body answers 409 with idempotency_key_conflict. While the first request is still running, a retry answers 409 with idempotency_request_in_progress and Retry-After. Server errors (5xx) are not remembered, so they can be retried with the same key.
Retry only network errors and 429 or 5xx answers, and wait longer between attempts. GET, PUT and DELETE requests are safe to repeat.
Rate limits
When a client sends too many requests, the API answers 429 with the code rate_limited and a Retry-After header with the number of seconds to wait. Repeated authentication failures from one address are limited too.
Wait at least the time given in Retry-After before you try again.
Versioning
The major version is part of the path (/api/v2). Within the v2, changes are additive: new operations, new optional parameters and new fields in responses. Ignore the fields you do not recognise.
Removing or renaming a field, changing a type or a status code, or changing an error code needs a new major version.
Resources
- Sites
10 operations
A site connects a CDN hostname to your origin, the server that holds your content. Each change to a site creates a configuration revision that is deployed to every edge location.
- Custom domains
5 operations
Serve a site from your own hostname, such as cdn.example.com. A custom domain is verified with DNS records before it is used.
- Certificates
6 operations
Certificates for your custom domains: managed certificates that CDNify obtains and renews for you, or your own certificates.
- Purge
3 operations
Remove cached content from every edge location, by path or all at once. Purges run asynchronously.
- Analytics
3 operations
Traffic, cache and error reports from the same data as the portal dashboards.
- Organization and team
7 operations
The organization your credential belongs to, its members, their roles and invitations.
- Authentication and API tokens
23 operations
Sessions of the customer portal, two-factor authentication, account sign-up and API tokens. Most of these operations accept only a signed-in session.
- Billing and usage
6 operations
Subscription, invoices, the open usage period and the payment method.
- Plans and entitlements
2 operations
The plans offered to your organization and the limits that apply to it.
- Notifications
3 operations
Notices for your organization and for you, as shown in the portal.
- Audit trail
1 operation
Who did what in your organization, and when.
- Reseller
4 operations
Customer accounts of a reseller organization and their usage.
The administrative API used by CDNify staff is served on a private network and is not part of this reference.
The legacy API v1 and the Reseller API keep working for existing integrations. API v1 and Reseller API reference