Core concepts
Errors
Sublaunch answers with an HTTP status and a JSON error whose type and code never change, so your code can branch on them.
The error object
Every error has the same shape. message is for people and may change, type and code are for your code. Every response, error or not, also carries its Request-Id header.
Attributes
- typestringThe family of the error, one per HTTP status.
- codestringWhat went wrong exactly. See the codes below.
- messagestringA sentence that explains the error.
- paramstring or nullThe parameter at fault, when there is one.
- request_idstringThe request's ID, the same as its
Request-Idheader. Send it to us when you need help. - doc_urlstringThis page, at the code's entry.
Response400
{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "limit must be an integer from 1 to 100.",
"param": "limit",
"request_id": "req_7Hq2LmX9pT4vK1sNb3Wd8YcQ",
"doc_url": "https://sublaunch.com/docs/errors#parameter_invalid"
}
}HTTP status codes
| Status | Type | Meaning |
|---|---|---|
| 400 | invalid_request_error | The request has a missing, unknown or invalid parameter. A request that conflicts with the Sublaunch, like a coupon code taken, gets this type with a 409, and a method the path does not take with a 405. |
| 401 | authentication_error | No key, a wrong key, a revoked key or an expired OAuth token. |
| 403 | permission_error | The key is valid but cannot do this, like a read key writing, a Sublaunch whose owner is on the Starter plan, or a team member without edit access. An email sent without enough AI credits gets this type with a 402. |
| 404 | not_found_error | No such object in the key's Sublaunch, or no such route. |
| 409 | idempotency_error | An Idempotency-Key was reused for another request, or its first request is still running. |
| 429 | rate_limit_error | Too many requests. Wait for Retry-After seconds. |
| 500 | api_error | Something went wrong on our side, a 501 for an endpoint not available yet, a 502 when a Sublaunch service did not answer. Retry later with the same Idempotency-Key. |
Error codes
| Code | Status | Meaning |
|---|---|---|
api_key_missing | 401 | The request has no Authorization or X-Api-Key header. |
api_key_invalid | 401 | No key matches, or the header is not Bearer and a key. Check that you copied all of it, sl_live_ included. |
api_key_revoked | 401 | The key was revoked in the app, or the team member who made it left the team. Create a new one. |
token_expired | 401 | An OAuth access token of an AI app expired. The app refreshes it on its own. |
insufficient_scope | 403 | The key has the read scope and the request changes data. Use a key with write. |
plan_required | 403 | The Sublaunch's owner is on the Starter plan. The API works on Business and Premium, and the same key works again once the Sublaunch is on one of them. |
insufficient_credits | 402 | The account has not enough AI credits to send this email. Quote a broadcast shows what it costs, AI credits are bought in the app. |
forbidden | 403 | The key's user may not do this, like a team member without edit access to this part of the Sublaunch, or an action the API does not offer. |
parameter_missing | 400 | A required parameter is missing. param names it. |
parameter_invalid | 400 | A parameter has a value the API does not accept, like a price above 100 000 or a date that is not ISO 8601. param names it. |
parameter_unknown | 400 | The query or the body has a parameter this endpoint does not take. param names it. |
body_invalid | 400 | The body is not valid JSON, or not a JSON object. |
cursor_invalid | 400 | The cursor is not one the API gave, was made for other filters, or goes deeper than 10 000 objects. |
idempotency_key_invalid | 400 | The Idempotency-Key is longer than 255 characters. |
method_not_allowed | 405 | This path does not take this method. The Allow header lists the ones it takes. |
validation_failed | 400 | The Sublaunch refused the change. The message says why. |
price_incomplete | 400 | A price of the draft has no amount yet, so the draft cannot be published. |
limit_reached | 400 | A limit is reached, like 5 tiers on a Sublaunch or 6 prices on a tier. A coupon past 200, a full team or a Sublaunch with 100 pages gets it with a 409. |
url_invalid | 400 | A webhook URL is not HTTPS, has credentials in it, uses a port other than 443 or 8443, does not resolve, or points to a private address. |
webhook_endpoint_limit_reached | 400 | The Sublaunch has 10 webhook endpoints already. Delete one first. |
username_taken | 409 | Another Sublaunch has this link, or it is reserved. |
resource_already_exists | 409 | It is there already, like a category with this name. |
code_taken | 409 | A coupon of the Sublaunch has this code already. |
tier_in_use | 409 | Members joined this tier, so it cannot be deleted. Archive its prices instead. |
price_in_use | 409 | Members bought this price, so it cannot be deleted. Archive it instead. |
post_locked | 409 | Someone liked, voted or commented the post, so its words can't change anymore. Its category and comments still can. |
comments_off | 409 | Comments are turned off for this post. |
already_member | 409 | This person is on the team already. |
slug_taken | 409 | Another page of the Sublaunch has this slug. Pick another one. |
broadcast_locked | 409 | The email cannot change or go out as it stands, like an email sent already, or scheduled and not paused. The message says what to do. |
resource_missing | 404 | No object with this ID in the key's Sublaunch. An ID of another Sublaunch answers the same. |
route_not_found | 404 | No endpoint at this path. |
idempotency_key_reused | 409 | This Idempotency-Key was used in the last 24 hours for a different method, path or body. |
idempotency_key_in_use | 409 | The first request with this Idempotency-Key is still running. Retry in a second. |
rate_limit_exceeded | 429 | More than 120 requests in the minute with this key, 300 on the Sublaunch, or a webhook limit. Wait for Retry-After seconds. |
internal_error | 500 | An unexpected error on our side. The request_id helps us find it. |
request_timeout | 500 | The request took too long. Narrow the filters, or retry with the same Idempotency-Key if it changes data. |
not_implemented | 501 | This endpoint is not available yet. |
upstream_unavailable | 502 | A Sublaunch service did not answer. Nothing changed, try again in a minute. |
upstream_error | 502 | A course could not be made. Try again. |
publish_failed | 502 | A course, an affiliate's commission, a page or an email of the draft could not be published. What comes after it stays in the draft, try again. |
Handle errors
- 400, 401, 403 and 404 never succeed as they are, nor a 409 that conflicts with the Sublaunch, like
code_taken. Fix the request before sending it again. - 409 with
idempotency_key_in_usesucceeds a second later. Retry with the sameIdempotency-Key. - 429 succeeds after
Retry-Afterseconds. See Rate limits. - 500 and 502 can be retried after a short wait. Send the same
Idempotency-Keyfor requests that change data, so nothing happens twice. - Log the
request_idof every error, it lets us find the request in seconds.