Getting Started

API Error Codes & Troubleshooting

Full error code reference for the TokPortal API. Error response format, HTTP status codes, and troubleshooting guide.

Errors

The TokPortal API uses a consistent error format across all endpoints. Errors are returned as JSON with an error object.

Error Response Format

{
  "error": {
    "code": "ERROR_CODE",
    "message": "A human-readable description of the problem.",
    "details": {}
  }
}
FieldTypeDescription
codestringMachine-readable error code. Use this for programmatic handling.
messagestringHuman-readable description. May change — do not match against this.
detailsobjectOptional. Additional context (e.g., which field failed validation, credit breakdown).

Every response also includes a correlation header:

X-TokPortal-Request-ID: req_...

Generated SDKs expose this value on structured API errors as requestId, request_id, or RequestID. Include it when contacting support about a failed request.

Error Code Reference

Authentication Errors

CodeHTTPDescription
AUTH_MISSING_KEY401No X-API-Key header was provided in the request.
AUTH_INVALID_KEY401The API key does not match any account.
AUTH_REVOKED_KEY401The API key has been revoked. Generate a new key from the developer dashboard.

Rate Limiting

CodeHTTPDescription
RATE_LIMIT_EXCEEDED429Too many requests. Wait and retry. See Rate Limits.

429 responses include Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.

Billing

CodeHTTPDescription
INSUFFICIENT_CREDITS402Not enough credits. Response includes required, available, missing, and breakdown in details.

Bundle Errors

CodeHTTPDescription
BUNDLE_NOT_FOUND404The specified bundle does not exist.
BUNDLE_NOT_OWNED403The bundle belongs to another account.
BUNDLE_INVALID_STATUS409The bundle is not in a valid status for this operation (e.g., trying to configure a published bundle).
BUNDLE_ALREADY_PUBLISHED409The bundle has already been published and cannot be modified.

Account Errors

CodeHTTPDescription
ACCOUNT_NOT_FOUND404The specified account does not exist.
ACCOUNT_INVALID_STATUS409The account is not in a valid status for this operation.
ACCOUNT_NOT_CONFIGURED409The account must be configured before this operation can proceed.

Saved Account Errors

CodeHTTPDescription
SAVED_ACCOUNT_NOT_FOUND404The specified saved account does not exist.
SAVED_ACCOUNT_NOT_OWNED403The saved account belongs to another user.

Video Errors

CodeHTTPDescription
VIDEO_NOT_FOUND404The specified video does not exist.
VIDEO_INVALID_STATUS409The video is not in a valid status for this operation.
VIDEO_POSITION_OUT_OF_RANGE400The video position exceeds the available slots.
VIDEO_NO_DOWNLOAD_ISSUE409The video does not have a download issue to fix.

Account Edit Request Errors

CodeHTTPDescription
EDIT_REQUEST_NO_CM400No manager assigned to this account.
EDIT_REQUEST_ALREADY_EXISTS409Another edit request is already in progress.
EDIT_REQUEST_NO_ACTIVE_ORDER400No active order for this account.

Validation Errors

CodeHTTPDescription
INVALID_COUNTRY400The country code is not supported.
INVALID_PLATFORM400The platform is not supported. Valid values: tiktok, instagram, youtube.
INVALID_VIDEO_TYPE400The video type is not valid for the target platform.
INVALID_DATE400The date is malformed or out of the allowed range.
INVALID_FIELD400A field value is invalid (details specify which field and why).
INVALID_BODY400The request body is malformed or not valid JSON.
MISSING_FIELD400A required field is missing from the request body.

Configuration Errors

CodeHTTPDescription
EDIT_SLOTS_EXCEEDED400The number of edit slots exceeds the allowed limit.
WARMING_CONFLICT400Conflicting warming options were specified.
DEEP_WARMING_PLATFORM400Deep warming is only available for Instagram accounts.
VIDEOS_ONLY_REQUIRES_ACCOUNT400A videos-only bundle requires an existing saved account.
ACCOUNT_ID_NOT_ALLOWED400The account_id field was passed with a bundle_type other than videos_only. To add videos to an existing saved account, set bundle_type to videos_only (this also skips the account-creation credit charge).

Analytics Errors

CodeHTTPDescription
ANALYTICS_COOLDOWN429Analytics were recently refreshed. Wait before requesting again.
ANALYTICS_QUOTA_EXCEEDED429Analytics refresh quota has been exceeded for this period.
ANALYTICS_NOT_FOUND404No analytics data is available for this account.

Verification Errors

CodeHTTPDescription
VERIFICATION_CODE_NOT_FOUND404No pending verification code was found for this account.

CSV Errors

CodeHTTPDescription
CSV_PARSE_ERROR400The CSV file could not be parsed. Check formatting and encoding.
CSV_VALIDATION_ERROR400The CSV content failed validation. details includes row-level errors.

Server Errors

CodeHTTPDescription
UPLOAD_FAILED500A file upload failed. Retry the request.
INTERNAL_ERROR500An unexpected server error occurred. If this persists, contact support.

Handling Errors in Code

const response = await fetch("https://app.tokportal.com/api/ext/bundles", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.TOKPORTAL_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(bundleConfig),
});

const result = await response.json();

if (result.error) {
  switch (result.error.code) {
    case "INSUFFICIENT_CREDITS":
      console.error(
        `Need ${result.error.details.missing} more credits.`
      );
      break;
    case "AUTH_INVALID_KEY":
      console.error("Invalid API key. Check your configuration.");
      break;
    case "RATE_LIMIT_EXCEEDED":
      // Wait and retry
      await new Promise((r) => setTimeout(r, 5000));
      break;
    default:
      console.error(`API error: ${result.error.message}`);
  }
}