Skip to content

API key

Returns the label, spending limit, usage in the current window and remaining amount of the API key making the request.

Markdown
On this page
GET/v1/key

Returns information about the key in the Authorization header, and only that key. A typical use is checking that a key has enough spending room left before you start a long batch job. All amounts are USD decimals.

Example

This example stops if less than 1 USD is left in the current window:

Request
curl https://api.getlykia.com/v1/key \
  -H "Authorization: Bearer $LYKIA_API_KEY"
Response200
{
  "data": {
    "label": "lyk-v1-ab12…ef90",
    "limit": 50,
    "limit_reset": "monthly",
    "usage": 18.47172,
    "limit_remaining": 31.52828,
    "company": {
      "id": "6b0472819bcb6b3a1239379b",
      "name": "Acme Products"
    },
    "project": {
      "id": "6b0472819bcb6b3a1239379d",
      "name": "Support bot"
    }
  }
}

Response

dataobject
labelstring

The masked key, for example lyk-v1-ab12…ef90. The full key is never returned by any endpoint.

limitnumber | null

The spending limit, or null for no limit.

limit_resetstring

When the limit resets: none (a lifetime limit that never resets), daily, weekly or monthly. Windows start on UTC boundaries.

usagenumber

What this key has spent in the current window.

limit_remainingnumber | null

What a new request can still use in the current window: the limit minus the window's usage minus what this key's requests in flight have reserved (0 once nothing is left), or null when there is no limit.

companyobject

The company the key belongs to: id and name.

projectobject

The project the key belongs to: id and name.