Better Auth in Rust
OpenAPI Reference

Api key

API Key plugin endpoints for creating, managing, and verifying API keys.

/api-key/create

POST
/api-key/create

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

name?string

Name of the Api Key

expiresIn*string

Expiration time of the Api Key in seconds

userId?string

User Id of the user that the Api Key belongs to. Useful for server-side only.

prefix?string

Prefix of the Api Key

remaining*string

Remaining number of requests. Server side only

metadata?string

Metadata of the Api Key

refillAmount?string

Amount to refill the remaining count of the Api Key. Server Only Property

refillInterval?string

Interval to refill the Api Key in milliseconds. Server Only Property.

rateLimitTimeWindow?string

The duration in milliseconds where each request is counted. Once the maxRequests is reached, the request will be rejected until the timeWindow has passed, at which point the timeWindow will be reset. Server Only Property.

rateLimitMax?string

Maximum amount of requests allowed within a window. Once the maxRequests is reached, the request will be rejected until the timeWindow has passed, at which point the timeWindow will be reset. Server Only Property.

rateLimitEnabled?string

Whether the key has rate limiting enabled. Server Only Property.

permissions?string

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/api-key/create" \  -H "Content-Type: application/json" \  -d '{    "expiresIn": "string",    "remaining": "string"  }'
{
  "id": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "name": "string",
  "prefix": "string",
  "start": "string",
  "key": "string",
  "enabled": true,
  "expiresAt": "2019-08-24T14:15:22Z",
  "userId": "string",
  "lastRefillAt": "2019-08-24T14:15:22Z",
  "lastRequest": "2019-08-24T14:15:22Z",
  "metadata": {},
  "rateLimitMax": 0,
  "rateLimitTimeWindow": 0,
  "remaining": 0,
  "refillAmount": 0,
  "refillInterval": 0,
  "rateLimitEnabled": true,
  "requestCount": 0,
  "permissions": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  }
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/api-key/get

GET
/api-key/get

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Query Parameters

id?string

The id of the Api Key

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/api-key/get"
{
  "id": "string",
  "name": "string",
  "start": "string",
  "prefix": "string",
  "userId": "string",
  "refillInterval": 0,
  "refillAmount": 0,
  "lastRefillAt": "2019-08-24T14:15:22Z",
  "enabled": true,
  "rateLimitEnabled": true,
  "rateLimitTimeWindow": 0,
  "rateLimitMax": 0,
  "requestCount": 0,
  "remaining": 0,
  "lastRequest": "2019-08-24T14:15:22Z",
  "expiresAt": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "metadata": {},
  "permissions": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/api-key/update

POST
/api-key/update

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

keyId*string

The id of the Api Key

userId?string
name?string

The name of the key

enabled?string

Whether the Api Key is enabled or not

remaining?string

The number of remaining requests

refillAmount?string

The refill amount

refillInterval?string

The refill interval

metadata?string

The metadata of the Api Key

expiresIn*string

Expiration time of the Api Key in seconds

rateLimitEnabled?string

Whether the key has rate limiting enabled.

rateLimitTimeWindow?string

The duration in milliseconds where each request is counted.

rateLimitMax?string

Maximum amount of requests allowed within a window. Once the maxRequests is reached, the request will be rejected until the timeWindow has passed, at which point the timeWindow will be reset.

permissions*string

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/api-key/update" \  -H "Content-Type: application/json" \  -d '{    "keyId": "string",    "expiresIn": "string",    "permissions": "string"  }'
{
  "id": "string",
  "name": "string",
  "start": "string",
  "prefix": "string",
  "userId": "string",
  "refillInterval": 0,
  "refillAmount": 0,
  "lastRefillAt": "2019-08-24T14:15:22Z",
  "enabled": true,
  "rateLimitEnabled": true,
  "rateLimitTimeWindow": 0,
  "rateLimitMax": 0,
  "requestCount": 0,
  "remaining": 0,
  "lastRequest": "2019-08-24T14:15:22Z",
  "expiresAt": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "metadata": {},
  "permissions": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/api-key/delete

POST
/api-key/delete

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Request Body

application/json

keyId*string

The id of the API key to delete

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "http://localhost:3001/api/auth/api-key/delete" \  -H "Content-Type: application/json" \  -d '{    "keyId": "string"  }'
{
  "success": true
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}

/api-key/list

GET
/api-key/list

Authorization

bearerAuth
AuthorizationBearer <token>

Bearer token authentication

In: header

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "http://localhost:3001/api/auth/api-key/list"
[
  {
    "id": "string",
    "name": "string",
    "start": "string",
    "prefix": "string",
    "userId": "string",
    "refillInterval": 0,
    "refillAmount": 0,
    "lastRefillAt": "2019-08-24T14:15:22Z",
    "enabled": true,
    "rateLimitEnabled": true,
    "rateLimitTimeWindow": 0,
    "rateLimitMax": 0,
    "requestCount": 0,
    "remaining": 0,
    "lastRequest": "2019-08-24T14:15:22Z",
    "expiresAt": "2019-08-24T14:15:22Z",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "metadata": {},
    "permissions": "string"
  }
]
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}
{
  "message": "string"
}