Skip to content
Dashboard

developers / Getting started

API errors and rate limits

What a failed hematite API request answers: the error codes, validation errors per field, rate limits per endpoint, their headers, and plan limits.

This page as Markdown

A request that fails answers a status of 400 or above, with JSON in the same shape as a success: a code to check in code, a message to read, and where there's more to say, data or issues.

404 Not Found
{
  "code": "API_ERROR",
  "message": "Not Found"
}

The codes

StatuscodeWhen
400VALIDATION_ERRORThe request doesn't match the endpoint's schema: a field missing, or of the wrong type
400API_ERRORThe request is well formed but can't be done; the message says why ("Invalid email or password")
401UNAUTHORIZEDNo token, or one that expired or was removed (authentication)
401REAUTH_REQUIREDA change that asks you to confirm it's you first (two-step sign-in); data.methods says how
402API_ERRORYour plan's limit is reached: "Storage limit reached" on an upload
403API_ERRORThe token may not do this: someone else's image, or an upload token on anything but an upload
403OAUTH_INSUFFICIENT_SCOPEAn app's token wasn't allowed the scope this needs; it's in data.scope (Sign in with hematite)
403OAUTH_ROUTE_DENIEDNo app's token may call this endpoint, whatever its scopes
403OAUTH_FIELD_DENIEDAn app's token sent a field no app may send here (a profile's email or privacy settings); they're in data.fields
403KEY_INSUFFICIENT_SCOPEAn API key wasn't made with the scope this needs; it's in data.scope (API keys)
403KEY_ROUTE_DENIEDNo API key may call this endpoint, whatever its scopes
403KEY_FIELD_DENIEDAn API key sent a field no key may send here; they're in data.fields
404API_ERRORIt doesn't exist
409API_ERRORIt conflicts with what's there: a fourth upload token, a domain that's taken
429RATE_LIMITEDToo many requests: wait and try again
429KEY_RATE_LIMITEDAn API key past its own rate a minute; Retry-After says when it may go on
429TOO_MANY_SIGN_INSTen wrong passwords for an address within 15 minutes; data.retryAt says when it can be tried again
500INTERNAL_ERRORSomething broke on hematite's side

Where an endpoint has errors of its own with data, its reference entry lists them.

Validation errors

A VALIDATION_ERROR says what was wrong, per part of the request, in data: body, query, params, headers or files, each a list of issues with the field's path and a message.

400 Bad Request
{
  "code": "VALIDATION_ERROR",
  "message": "Request validation failed.",
  "data": {
    "body": [
      {
        "code": "invalid_type",
        "expected": "string",
        "path": ["title"],
        "message": "Invalid input: expected string, received number"
      }
    ]
  }
}

An upload that's too large or of a type hematite doesn't take is a validation error too, under files.

Rate limits

Each endpoint counts requests per address in a fixed window: 120 a minute unless its reference entry says otherwise. Endpoints that count something, like downloads, allow fewer, and uploading takes 60 a minute. To send more, wait for the next window when a 429 says to, as hematite's own upload page does.

Every answer says where you stand, in three headers:

HeaderWhat it says
RateLimit-LimitHow many requests the window allows
RateLimit-RemainingHow many are left in it
RateLimit-ResetWhen it starts over, in seconds since 1970 (Unix time)

Past the limit, the answer is 429 with the code RATE_LIMITED and a Retry-After header: the seconds to wait. A page on another site can read all four headers too: the API exposes them to browsers.

429 Too Many Requests
{
  "code": "RATE_LIMITED",
  "message": "Too many requests. Please slow down and try again."
}

Plan limits

How much you can store and how many folders you can have depend on your plan: see pricing. An upload past your storage answers 402 with how much you use and how much you have, in data.storageUsed and data.storageLimit, in bytes.