EdgeLock API Reference

Complete reference documentation for the EdgeLock API endpoints, parameters, and responses.

Base URL

https://api.edgelock.dev

Authentication

The EdgeLock API uses API keys to authenticate requests. You can manage your API keys in the EdgeLock Dashboard.

Your API key carries many privileges, so be sure to keep it secret! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

Using the API Key

Include your API key in the `Authorization` header for all requests:

Authorization: Bearer YOUR_API_KEY
GET

/

Health check to verify the API is operational.

Response

{
  "ok": true,
  "data": {
    "message": "Hello, World!"
  }
}
POST

/lock/:key

Acquire a distributed lock for a specific key.

Path Parameters

ParameterTypeDescription
keystringThe identifier to lock

Request Body

JSON (optional)

{
  "ttl": 300  // Lock duration in seconds (1-86400)
}

Responses

{
  "ok": true,
  "data": {
    "lockId": "lock_01HNZ6EQPCRYXGZS4QFJT2X5QK",
    "expiresAt": "2024-04-16T15:30:45Z"
  }
}
POST

/unlock/:key

Release a previously acquired lock for a specific key.

Path Parameters

ParameterTypeDescription
keystringThe identifier to unlock

Request Body

JSON (required)

{
  "lockId": "lock_01HNZ6EQPCRYXGZS4QFJT2X5QK"  // The ID of the lock to release
}

Responses

{
  "ok": true,
  "data": {
    "released": true
  }
}
GET

/status/:key

Get the current lock status for a specific key.

Path Parameters

ParameterTypeDescription
keystringThe identifier to check

Responses

{
  "ok": true,
  "data": {
    "locked": true,
    "lockId": "lock_01HNZ6EQPCRYXGZS4QFJT2X5QK",
    "expiresAt": "2024-04-16T15:30:45Z"
  }
}