{
  "openapi": "3.1.0",
  "info": {
    "title": "Bludia Public API",
    "version": "1.0.0",
    "description": "The Bludia public REST API (v1). Every request requires the `X-BLUDIA-API-KEY` header. With an `end_users` key, data and account routes also require `Authorization: Bearer <access_token>` from login. With a `platform` key, the API key alone grants full project access."
  },
  "servers": [
    {
      "url": "https://{host}/ext/api/v1",
      "description": "Your Bludia API host. Copy it from a collection's API Endpoints panel.",
      "variables": {
        "host": {
          "default": "YOUR_API_HOST",
          "description": "API host shown in your dashboard"
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Records",
      "description": "Create, read, update, and delete records in a collection."
    },
    {
      "name": "Authentication",
      "description": "Register, log in, refresh, and log out end users through an authentication guard."
    },
    {
      "name": "Account",
      "description": "Endpoints for the signed-in end user."
    }
  ],
  "security": [
    {
      "ApiKey": [],
      "BearerAuth": []
    },
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/collections/{collection}/records": {
      "get": {
        "tags": [
          "Records"
        ],
        "summary": "List records",
        "operationId": "listRecords",
        "description": "Returns a page of records. End users only see records allowed by their row policies. Requires `can_read` for end users.",
        "parameters": [
          {
            "name": "collection",
            "in": "path",
            "required": true,
            "description": "Collection slug, for example `orders`.",
            "schema": {
              "type": "string"
            },
            "example": "orders"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            },
            "description": "Page number."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            },
            "description": "Records per page (max 100)."
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "updated_at",
                "published_at",
                "id"
              ],
              "default": "created_at"
            },
            "description": "Sort column."
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            },
            "description": "Sort direction."
          },
          {
            "name": "filters",
            "in": "query",
            "style": "deepObject",
            "explode": true,
            "schema": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "Filter by field name, for example `filters[status]=paid`, `filters[total][min]=100`, `filters[name][value]=ahm&filters[name][match_mode]=starts_with`. See Filtering docs."
          },
          {
            "name": "conditions",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "JSON array of conditions on system columns (`id`, `created_at`, `updated_at`, `published_at`, `status`), for example `[{\"field\":\"created_at\",\"op\":\">=\",\"value\":\"2026-11-01\"}]`."
          },
          {
            "name": "with",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated related collection slugs to include under `children`. Use dots for nesting: `orders.order_items`."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of records.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordList"
                },
                "example": {
                  "data": [
                    {
                      "id": 101,
                      "slug": null,
                      "created_at": "2026-11-20T09:15:00.000000Z",
                      "updated_at": "2026-11-20T09:15:00.000000Z",
                      "published_at": "2026-11-20T09:15:00.000000Z",
                      "children": [],
                      "title": "Order #101",
                      "status": "confirmed",
                      "total": "120.00",
                      "customer": {
                        "id": 25,
                        "label": "Sarah Ahmed"
                      }
                    }
                  ],
                  "meta": {
                    "page": 1,
                    "limit": 20,
                    "total": 1,
                    "pages": 1,
                    "trashed": 0
                  },
                  "totals": []
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/collections/{collection}": {
      "post": {
        "tags": [
          "Records"
        ],
        "summary": "Create a record",
        "operationId": "createRecord",
        "description": "Creates a record. Send field values keyed by field name; unknown keys are ignored. Runs validation and `beforeInsert`/`afterInsert` hooks. When an end user creates the record, they become its owner. Requires `can_create` for end users.",
        "parameters": [
          {
            "name": "collection",
            "in": "path",
            "required": true,
            "description": "Collection slug, for example `orders`.",
            "schema": {
              "type": "string"
            },
            "example": "orders"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordInput"
              },
              "example": {
                "title": "Order #102",
                "status": "pending",
                "customer": 25
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordEnvelope"
                },
                "example": {
                  "data": {
                    "id": 101,
                    "slug": null,
                    "created_at": "2026-11-20T09:15:00.000000Z",
                    "updated_at": "2026-11-20T09:15:00.000000Z",
                    "published_at": "2026-11-20T09:15:00.000000Z",
                    "children": [],
                    "title": "Order #101",
                    "status": "confirmed",
                    "total": "120.00",
                    "customer": {
                      "id": 25,
                      "label": "Sarah Ahmed"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/collections/{collection}/{id}": {
      "get": {
        "tags": [
          "Records"
        ],
        "summary": "Get a record",
        "operationId": "getRecord",
        "description": "Returns one record. Returns 404 if it doesn't exist, is in the trash, or isn't visible to the end user. Requires `can_read` for end users.",
        "parameters": [
          {
            "name": "collection",
            "in": "path",
            "required": true,
            "description": "Collection slug, for example `orders`.",
            "schema": {
              "type": "string"
            },
            "example": "orders"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record ID.",
            "schema": {
              "type": "integer"
            },
            "example": 101
          }
        ],
        "responses": {
          "200": {
            "description": "The record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordEnvelope"
                },
                "example": {
                  "data": {
                    "id": 101,
                    "slug": null,
                    "created_at": "2026-11-20T09:15:00.000000Z",
                    "updated_at": "2026-11-20T09:15:00.000000Z",
                    "published_at": "2026-11-20T09:15:00.000000Z",
                    "children": [],
                    "title": "Order #101",
                    "status": "confirmed",
                    "total": "120.00",
                    "customer": {
                      "id": 25,
                      "label": "Sarah Ahmed"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "tags": [
          "Records"
        ],
        "summary": "Update a record",
        "operationId": "updateRecord",
        "description": "Partially updates a record: omitted fields are unchanged, `null` or empty string clears a field. Send `version` (or an `If-Match` header) to get `409` instead of overwriting a newer change. Runs `beforeUpdate`/`afterUpdate` hooks. Requires `can_update` for end users.",
        "parameters": [
          {
            "name": "collection",
            "in": "path",
            "required": true,
            "description": "Collection slug, for example `orders`.",
            "schema": {
              "type": "string"
            },
            "example": "orders"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record ID.",
            "schema": {
              "type": "integer"
            },
            "example": 101
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Record version you loaded, for example `\"3\"`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordInput"
              },
              "example": {
                "status": "confirmed",
                "version": 3
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordEnvelope"
                },
                "example": {
                  "data": {
                    "id": 101,
                    "slug": null,
                    "created_at": "2026-11-20T09:15:00.000000Z",
                    "updated_at": "2026-11-20T09:15:00.000000Z",
                    "published_at": "2026-11-20T09:15:00.000000Z",
                    "children": [],
                    "title": "Order #101",
                    "status": "confirmed",
                    "total": "120.00",
                    "customer": {
                      "id": 25,
                      "label": "Sarah Ahmed"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The record changed since the given version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": [
          "Records"
        ],
        "summary": "Delete a record",
        "operationId": "deleteRecord",
        "description": "Moves the record to the trash (soft delete). Runs `beforeDelete`/`afterDelete` hooks. Requires `can_delete` for end users.",
        "parameters": [
          {
            "name": "collection",
            "in": "path",
            "required": true,
            "description": "Collection slug, for example `orders`.",
            "schema": {
              "type": "string"
            },
            "example": "orders"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record ID.",
            "schema": {
              "type": "integer"
            },
            "example": 101
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "Record deleted"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/register": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Register",
        "operationId": "register",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "description": "Creates an end-user account in the guard's collection and returns a session. Send the login field under its field name, `password` (min 8), and any other fields. Assigns the guard's default `user` role. If email verification is on, the response includes `status: pending_verification` and a code is emailed. Limited to 10 requests per minute per IP.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "password"
                ],
                "properties": {
                  "password": {
                    "type": "string",
                    "minLength": 8,
                    "format": "password"
                  }
                },
                "additionalProperties": true,
                "description": "Login field (by field name), password, and other fields."
              },
              "example": {
                "email": "sarah@example.com",
                "password": "correct horse battery",
                "full_name": "Sarah Ahmed"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered and signed in.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegisterResponse"
                },
                "example": {
                  "session": {
                    "access_token": "eyJhbGciOiJIUzI1NiIs...",
                    "refresh_token": "q3Jx...",
                    "token_type": "Bearer",
                    "expires_in": 900,
                    "record_id": 42
                  }
                }
              }
            }
          },
          "403": {
            "description": "`registration_disabled`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "409": {
            "description": "`duplicate_account`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Log in",
        "operationId": "login",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "description": "Exchanges a login value and password for a session. Users with status `inactive`, `banned`, or `suspended` get `403 account_inactive`. Limited to 10 requests per minute per IP.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "login",
                  "password"
                ],
                "properties": {
                  "login": {
                    "type": "string",
                    "description": "Value of the guard's login field (email, username, phone\u2026)."
                  },
                  "password": {
                    "type": "string",
                    "format": "password"
                  }
                }
              },
              "example": {
                "login": "sarah@example.com",
                "password": "correct horse battery"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed in.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                },
                "example": {
                  "session": {
                    "access_token": "eyJhbGciOiJIUzI1NiIs...",
                    "refresh_token": "q3Jx...",
                    "token_type": "Bearer",
                    "expires_in": 900,
                    "record_id": 42
                  }
                }
              }
            }
          },
          "401": {
            "description": "`invalid_credentials`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                },
                "example": {
                  "error": "invalid_credentials",
                  "message": "The provided credentials are incorrect."
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/refresh": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Refresh session",
        "operationId": "refresh",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "description": "Returns a new access token and refresh token. The refresh token you send is revoked (rotation); store the new one.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "refresh_token"
                ],
                "properties": {
                  "refresh_token": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "refresh_token": "q3Jx..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                },
                "example": {
                  "access_token": "eyJhbGciOiJIUzI1NiIs...",
                  "refresh_token": "q3Jx...",
                  "token_type": "Bearer",
                  "expires_in": 900,
                  "record_id": 42
                }
              }
            }
          },
          "401": {
            "description": "`invalid_or_expired_token`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/password/forgot": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Request password reset",
        "operationId": "forgotPassword",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "description": "Issues a single-use reset token valid for 60 minutes. Always returns the same message, whether or not the account exists.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "login"
                ],
                "properties": {
                  "login": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "login": "sarah@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "If an account exists, password reset instructions have been sent."
                }
              }
            }
          },
          "403": {
            "description": "`password_reset_disabled`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/password/reset": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Reset password",
        "operationId": "resetPassword",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "description": "Sets a new password using a reset token and revokes all of the user's sessions.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token",
                  "password"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 8,
                    "format": "password"
                  }
                }
              },
              "example": {
                "token": "RESET_TOKEN",
                "password": "a new strong passphrase"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "Password has been reset. Please log in again."
                }
              }
            }
          },
          "401": {
            "description": "`invalid_or_expired_token`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/email/verify": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Verify email",
        "operationId": "verifyEmail",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "description": "Confirms the 6-character code emailed at registration and sets the account status to `active`.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "token": "7KQ2XF"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "Email verified. You can now log in."
                }
              }
            }
          },
          "401": {
            "description": "`invalid_or_expired_token`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/me": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Get current user",
        "operationId": "me",
        "security": [
          {
            "ApiKey": [],
            "BearerAuth": []
          }
        ],
        "description": "Returns the signed-in user's record. Profile fields are in `data` by field name; the password is never included. `data.verified_at` is present once the email is verified.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "responses": {
          "200": {
            "description": "The user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentUser"
                },
                "example": {
                  "id": 42,
                  "status": "active",
                  "created_at": "2026-11-01 08:30:00",
                  "updated_at": "2026-11-18 16:02:11",
                  "data": {
                    "email": "sarah@example.com",
                    "full_name": "Sarah Ahmed",
                    "verified_at": "2026-11-01 08:34:12"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/logout": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Log out",
        "operationId": "logout",
        "security": [
          {
            "ApiKey": [],
            "BearerAuth": []
          }
        ],
        "description": "Revokes one refresh token (this device). Access tokens stay valid until they expire.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "refresh_token"
                ],
                "properties": {
                  "refresh_token": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "refresh_token": "q3Jx..."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Logged out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "Logged out."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/logout-all": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Log out everywhere",
        "operationId": "logoutAll",
        "security": [
          {
            "ApiKey": [],
            "BearerAuth": []
          }
        ],
        "description": "Revokes all of the user's refresh tokens.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "responses": {
          "200": {
            "description": "All sessions revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "All sessions revoked."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/{guard}/email/resend": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Resend verification code",
        "operationId": "resendVerification",
        "security": [
          {
            "ApiKey": [],
            "BearerAuth": []
          }
        ],
        "description": "Issues a new email verification code for the signed-in user.",
        "parameters": [
          {
            "name": "guard",
            "in": "path",
            "required": true,
            "description": "Authentication guard slug, for example `users`.",
            "schema": {
              "type": "string"
            },
            "example": "users"
          }
        ],
        "responses": {
          "200": {
            "description": "New code issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                },
                "example": {
                  "message": "Verification email sent."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-BLUDIA-API-KEY",
        "description": "Your project API key, for example `bludia_production_k3x9qa_...`."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "End-user access token from login, register, or refresh. Required with `end_users` keys."
      }
    },
    "schemas": {
      "Record": {
        "type": "object",
        "description": "System fields plus one key per collection field (by field name). Relation fields are `{id, label}` objects or arrays of them.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "slug": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "children": {
            "description": "Related records requested with `with`, keyed by collection name.",
            "oneOf": [
              {
                "type": "array"
              },
              {
                "type": "object",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            ]
          }
        },
        "additionalProperties": true
      },
      "RecordInput": {
        "type": "object",
        "description": "Field values by field name. Optional system fields: `slug`, `published_at`. On update, optional `version` for optimistic concurrency.",
        "properties": {
          "slug": {
            "type": "string"
          },
          "published_at": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "RecordEnvelope": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Record"
          }
        },
        "required": [
          "data"
        ]
      },
      "RecordList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Record"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          },
          "totals": {
            "description": "Column totals configured in collection settings."
          }
        },
        "required": [
          "data",
          "meta"
        ]
      },
      "PageMeta": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total": {
            "type": "integer",
            "description": "Matching records visible to the caller."
          },
          "pages": {
            "type": "integer"
          },
          "trashed": {
            "type": "integer",
            "description": "Matching records in the trash."
          }
        }
      },
      "Session": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": "JWT, valid for `expires_in` seconds."
          },
          "refresh_token": {
            "type": "string",
            "description": "Opaque token; rotates on every refresh."
          },
          "token_type": {
            "type": "string",
            "const": "Bearer"
          },
          "expires_in": {
            "type": "integer",
            "description": "Seconds until the access token expires (default 900)."
          },
          "record_id": {
            "type": "integer",
            "description": "The user's record ID."
          }
        }
      },
      "SessionResponse": {
        "type": "object",
        "properties": {
          "session": {
            "$ref": "#/components/schemas/Session"
          }
        }
      },
      "RegisterResponse": {
        "type": "object",
        "properties": {
          "session": {
            "$ref": "#/components/schemas/Session"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_verification"
            ],
            "description": "Present when email verification is on."
          }
        }
      },
      "CurrentUser": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "pending",
              "inactive",
              "banned",
              "suspended"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "Message": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        }
      },
      "AuthError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable code, for example `invalid_credentials`."
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "status": {
            "type": "boolean",
            "const": false
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "description": "Field errors, when available."
          },
          "request_id": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid API key or access token.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            },
            "example": {
              "message": "Missing API key."
            }
          }
        }
      },
      "Forbidden": {
        "description": "Key revoked or expired, origin not allowed, or no permission.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AuthError"
            },
            "example": {
              "error": "permission_denied",
              "message": "You do not have [delete] permission on collection [14]."
            }
          }
        }
      },
      "NotFound": {
        "description": "Collection, guard, or record not found (or not visible).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ValidationError": {
        "description": "Validation failed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Message"
            },
            "example": {
              "message": "Rate limit exceeded."
            }
          }
        }
      }
    }
  }
}