OAuth Clients

OAuth clients represent third-party applications that access the Snapbooks API on behalf of users. Before an application can use OAuth2 flows (authorization code, client credentials, or refresh token), it must be registered as a client.

There are two ways to register a client:

  • Authenticated registration — Create a client tied to your user account via the authenticated API.
  • Dynamic registration — Self-register a client via the public endpoint without prior authentication (RFC 7591).

A public client can also skip registration entirely and use the URL of its client metadata document as its client_id; see Client ID Metadata Documents.

For details on how to use OAuth clients in authentication flows, see OAuth2 Authentication.

Endpoints

Method Endpoint Description
POST /oauth/register Dynamic client registration (public)
POST /oauth/clients Create an OAuth client
GET /oauth/clients List your OAuth clients
DELETE /oauth/clients/{client_id} Delete an OAuth client

Dynamic Client Registration

POST /public/v2/oauth/register

Public endpoint for dynamic client registration per RFC 7591. No authentication is required. Rate limited to 300 requests per hour.

Dynamically registered clients are owned by the system user and cannot be listed or managed via the authenticated client endpoints. Because of that they are limited to user-delegated grants: client_credentials is not allowed.

Request Body

Field Type Required Description
client_name string Yes Display name for the client application
redirect_uris array Yes Non-empty array of redirect URIs. Each must use HTTPS, or plain HTTP on a loopback host (localhost, 127.0.0.1, ::1)
grant_types array No Allowed grant types: authorization_code and refresh_token. Default: both
response_types array No Allowed response types. Default: ["code"]. Only code is supported
scope string No Requested scope: read, write, or both. Defaults to read write. See Authentication
token_endpoint_auth_method string No Authentication method. Default: client_secret_post. Allowed: client_secret_post, client_secret_basic, none

Allowed Grant Types

Value Description
authorization_code For user-facing applications
refresh_token For obtaining new access tokens

Public Clients

Register with token_endpoint_auth_method: none for a client that cannot keep a secret, such as a desktop or command-line app. No client_secret is issued; the client sends its client_id alone to the token endpoint, and PKCE (required on every authorization request) binds the code to it.

Example Request

{
  "client_name": "My Integration",
  "redirect_uris": ["https://myapp.example.com/callback"],
  "grant_types": ["authorization_code", "refresh_token"],
  "scope": "read"
}

Response

{
  "client_id": "<client-id>",
  "client_name": "My Integration",
  "redirect_uris": ["https://myapp.example.com/callback"],
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "scope": "read",
  "token_endpoint_auth_method": "client_secret_post",
  "client_id_issued_at": 1712764800,
  "client_secret": "<client-secret>",
  "client_secret_expires_at": 0
}

client_secret_expires_at is 0: the secret does not expire. A public client (token_endpoint_auth_method: none) gets neither field.

Important: Store the client_secret securely — only a hash of it is stored, so it cannot be retrieved later.

Error Responses

Status Description
400 Missing or invalid client_name
400 redirect_uris is missing, not an array, or empty
400 Redirect URI does not use HTTPS and is not plain HTTP on a loopback host
400 Unsupported grant_types (including client_credentials) or response_types
400 Invalid token_endpoint_auth_method
400 Unknown scope value — only read and write are supported
429 Rate limit exceeded (300 per hour)

Create an OAuth Client

POST /api/v2/oauth/clients

Creates a new OAuth client tied to the authenticated user.

Request Body

Field Type Required Description
client_name string Yes Display name for the client application
redirect_uris string Conditional Space-separated redirect URIs. Required when grant_types includes authorization_code
grant_types string No Space-separated grant types. Default: authorization_code refresh_token
scope string No Requested scope: read, write, or both. Defaults to read write. See Authentication

Clients created here are always confidential: a client_secret is issued.

Example Request

{
  "client_name": "My Accounting App",
  "redirect_uris": "https://myapp.example.com/callback",
  "grant_types": "authorization_code refresh_token",
  "scope": "read write"
}

Response

{
  "client_id": "<client-id>",
  "client_secret": "<client-secret>",
  "client_name": "My Accounting App",
  "redirect_uris": "https://myapp.example.com/callback",
  "grant_types": "authorization_code refresh_token",
  "scope": "read write"
}

Important: Store the client_secret securely — only a hash of it is stored, so it cannot be retrieved later.

Error Responses

Status Description
400 Missing client_name
400 Missing redirect_uris when using authorization code grant
400 Redirect URI does not use HTTPS and is not plain HTTP on a loopback host
400 Unknown scope value — only read and write are supported

List OAuth Clients

GET /api/v2/oauth/clients

Returns all OAuth clients owned by the authenticated user. The client_secret is not included in the response.

Response

{
  "clients": [
    {
      "client_id": "<client-id>",
      "client_name": "My Accounting App",
      "redirect_uris": "https://myapp.example.com/callback",
      "grant_types": "authorization_code refresh_token",
      "scope": "read write",
      "created_at": "2026-03-15T10:00:00.000000"
    }
  ]
}

Delete an OAuth Client

DELETE /api/v2/oauth/clients/{client_id}

Deletes an OAuth client and revokes all associated refresh tokens. The client must be owned by the authenticated user.

Path Parameters

Parameter Type Description
client_id string The OAuth client ID

Response

{
  "status": "success",
  "message": "Client deleted"
}

Error Responses

Status Description
400 Client not found or not owned by the authenticated user

Attributes

OAuth Client

Attribute Type Description
client_id string Unique client identifier (read-only)
client_secret string Client secret. Only returned on creation, and never for a public client
client_name string Display name for the client application
redirect_uris string or array Allowed redirect URIs. String (space-separated) for authenticated registration, array for dynamic registration
grant_types string or array Allowed OAuth grant types
scope string Token scope
created_at datetime Creation timestamp (read-only, only in list response)

Notes

  • The authenticated endpoints (/api/v2/oauth/clients) use space-separated strings for redirect_uris and grant_types.
  • The dynamic registration endpoint (/public/v2/oauth/register) uses arrays for redirect_uris and grant_types, per RFC 7591.
  • Deleting a client automatically revokes all associated refresh tokens. Access tokens (JWT) remain valid until they expire.
  • Only code is supported as a response_type.