{
  "openapi": "3.1.0",
  "info": {
    "title": "Pocket Alert API",
    "version": "1.1.0",
    "summary": "Send push notifications to iOS and Android devices.",
    "description": "REST API of Pocket Alert (https://pocketalert.app). One authenticated request delivers a push notification to the account's phones. Also covers applications (channels), devices, webhook receivers, forms and API keys.\n\nAuthenticate with an API key in the `Token` header (https://pocketalert.app/account/apikeys) or a JWT in `Authorization: Bearer`. Full guide: https://pocketalert.app/auth.md\n\nOfficial SDKs: Node.js (`npm i pocketalert`), Python (`pip install pocketalert`), Go (`github.com/PocketAlert/pocketalert-go`), PHP (`composer require pocketalert/pocketalert-php`).\n\nErrors are JSON `{\"error\": \"...\"}`. Timestamps named `created_at`/`deliver_at` use the display format `DD.MM.YYYY HH:MM:SS` in the account timezone; `*_utc` and `resets_at` are RFC 3339.",
    "termsOfService": "https://pocketalert.app/terms",
    "contact": {
      "name": "Pocket Alert support",
      "url": "https://pocketalert.app/contact",
      "email": "info@pocketalert.app"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://pocketalert.app/terms"
    }
  },
  "externalDocs": {
    "description": "Human documentation",
    "url": "https://info.pocketalert.app/"
  },
  "servers": [
    {
      "url": "https://api.pocketalert.app",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Messages",
      "description": "Send and manage push notifications"
    },
    {
      "name": "Scheduled messages",
      "description": "Messages waiting for delayed delivery"
    },
    {
      "name": "Applications",
      "description": "Channels that group notifications"
    },
    {
      "name": "Devices",
      "description": "Phones registered to the account"
    },
    {
      "name": "Webhooks",
      "description": "Inbound receivers that turn third-party payloads into notifications"
    },
    {
      "name": "Forms",
      "description": "Hosted forms whose submissions become notifications"
    },
    {
      "name": "API keys",
      "description": "Credentials for the `Token` header"
    },
    {
      "name": "Auth",
      "description": "Sign-in"
    }
  ],
  "paths": {
    "/v1/messages": {
      "post": {
        "tags": ["Messages"],
        "operationId": "sendMessage",
        "summary": "Send a push notification",
        "description": "Delivers a notification to every device on the account, or to one device when `device_id` is set. With `send_at`/`delay` in the future the message is stored and delivered later (paid plans). Each accepted request counts toward the daily limit; rejected ones do not.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageCreate"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/MessageCreateMultipart"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sent, or scheduled",
            "headers": {
              "X-PA-Daily-Limit": {
                "$ref": "#/components/headers/DailyLimit"
              },
              "X-PA-Daily-Remaining": {
                "$ref": "#/components/headers/DailyRemaining"
              },
              "X-PA-Daily-Reset": {
                "$ref": "#/components/headers/DailyReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/SentMessage"
                    },
                    {
                      "$ref": "#/components/schemas/ScheduledMessageCreated"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/DailyLimit"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "get": {
        "tags": ["Messages"],
        "operationId": "listAllMessages",
        "summary": "List messages (unpaginated)",
        "description": "Returns every message unless `limit` is set. Prefer `GET /v2/messages` for paging.",
        "parameters": [
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "tid",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Only messages targeted at this device TID"
          }
        ],
        "responses": {
          "200": {
            "description": "Messages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Message"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v2/messages": {
      "get": {
        "tags": ["Messages"],
        "operationId": "listMessages",
        "summary": "List messages, paginated",
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "size",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1000
            },
            "description": "Page size"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"],
              "default": "desc"
            }
          },
          {
            "name": "tid",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Only messages targeted at this device TID"
          }
        ],
        "responses": {
          "200": {
            "description": "Message page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagePage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "get": {
        "tags": ["Messages"],
        "operationId": "getMessage",
        "summary": "Get one message",
        "description": "Reading a message marks it as read. A missing resource is currently answered with `500` and the body `{\"error\": \"record not found\"}`; treat that pair as not found.",
        "responses": {
          "200": {
            "description": "Message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "tags": ["Messages"],
        "operationId": "markMessageRead",
        "summary": "Mark a message as read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "tags": ["Messages"],
        "operationId": "deleteMessage",
        "summary": "Delete a message and its attachment",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/read-all": {
      "put": {
        "tags": ["Messages"],
        "operationId": "markAllMessagesRead",
        "summary": "Mark every message as read",
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/bulk": {
      "delete": {
        "tags": ["Messages"],
        "operationId": "deleteAllMessages",
        "summary": "Delete every message on the account",
        "description": "Irreversible.",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/stat": {
      "get": {
        "tags": ["Messages"],
        "operationId": "getMessageStats",
        "summary": "Message counts per day (account timezone)",
        "responses": {
          "200": {
            "description": "Per-day counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessageStat"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/usage": {
      "get": {
        "tags": ["Messages"],
        "operationId": "getMessageUsage",
        "summary": "Today's usage against the daily message limit",
        "responses": {
          "200": {
            "description": "Usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageUsage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/scheduled": {
      "get": {
        "tags": ["Scheduled messages"],
        "operationId": "listScheduledMessages",
        "summary": "List scheduled messages",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["all", "pending", "sending", "sent", "canceled", "failed"]
            },
            "description": "Defaults to `pending`"
          }
        ],
        "responses": {
          "200": {
            "description": "Scheduled messages, soonest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ScheduledMessage"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/messages/scheduled/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "delete": {
        "tags": ["Scheduled messages"],
        "operationId": "cancelScheduledMessage",
        "summary": "Cancel a pending scheduled message",
        "responses": {
          "200": {
            "description": "Canceled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCancelResult"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/applications": {
      "get": {
        "tags": ["Applications"],
        "operationId": "listApplications",
        "summary": "List applications",
        "responses": {
          "200": {
            "description": "Applications",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Application"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "tags": ["Applications"],
        "operationId": "createApplication",
        "summary": "Create an application",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/ApplicationInput"
                  },
                  {
                    "required": ["name"]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/applications/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "get": {
        "tags": ["Applications"],
        "operationId": "getApplication",
        "summary": "Get one application",
        "description": "A missing resource is currently answered with `500` and the body `{\"error\": \"record not found\"}`; treat that pair as not found.",
        "responses": {
          "200": {
            "description": "Application",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "tags": ["Applications"],
        "operationId": "updateApplication",
        "summary": "Update an application",
        "description": "Only non-empty fields are changed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "tags": ["Applications"],
        "operationId": "deleteApplication",
        "summary": "Delete an application",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/devices": {
      "get": {
        "tags": ["Devices"],
        "operationId": "listDevices",
        "summary": "List registered devices",
        "responses": {
          "200": {
            "description": "Devices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Device"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/devices/tid/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "get": {
        "tags": ["Devices"],
        "operationId": "getDevice",
        "summary": "Get one device",
        "description": "A missing resource is currently answered with `500` and the body `{\"error\": \"record not found\"}`; treat that pair as not found.",
        "responses": {
          "200": {
            "description": "Device",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Device"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/devices/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "put": {
        "tags": ["Devices"],
        "operationId": "updateDevice",
        "summary": "Rename a device",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "tags": ["Devices"],
        "operationId": "deleteDevice",
        "summary": "Remove a device",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/webhooks": {
      "get": {
        "tags": ["Webhooks"],
        "operationId": "listWebhooks",
        "summary": "List webhook receivers",
        "responses": {
          "200": {
            "description": "Webhooks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Webhook"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "tags": ["Webhooks"],
        "operationId": "createWebhook",
        "summary": "Create a webhook receiver",
        "description": "Third-party services post JSON to `https://p4a.me/wh/{url}`; the payload is rendered with `message`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/webhooks/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "get": {
        "tags": ["Webhooks"],
        "operationId": "getWebhook",
        "summary": "Get one webhook",
        "description": "A missing resource is currently answered with `500` and the body `{\"error\": \"record not found\"}`; treat that pair as not found.",
        "responses": {
          "200": {
            "description": "Webhook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "tags": ["Webhooks"],
        "operationId": "updateWebhook",
        "summary": "Replace a webhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "tags": ["Webhooks"],
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook and its history",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/webhooks/{tid}/history": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "get": {
        "tags": ["Webhooks"],
        "operationId": "getWebhookHistory",
        "summary": "Recorded inbound requests for a webhook",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["success", "error"]
            },
            "description": "Filter by outcome"
          }
        ],
        "responses": {
          "200": {
            "description": "History page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookHistory"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/forms": {
      "get": {
        "tags": ["Forms"],
        "operationId": "listForms",
        "summary": "List forms",
        "responses": {
          "200": {
            "description": "Forms",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Form"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "tags": ["Forms"],
        "operationId": "createForm",
        "summary": "Create a form",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Form"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/forms/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "put": {
        "tags": ["Forms"],
        "operationId": "updateForm",
        "summary": "Replace a form definition",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Form"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "tags": ["Forms"],
        "operationId": "deleteForm",
        "summary": "Delete a form",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/apikeys": {
      "get": {
        "tags": ["API keys"],
        "operationId": "listApiKeys",
        "summary": "List API keys",
        "responses": {
          "200": {
            "description": "API keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiKey"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "tags": ["API keys"],
        "operationId": "createApiKey",
        "summary": "Create an API key",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "examples": ["ci-agent"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/apikeys/{tid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Tid"
        }
      ],
      "delete": {
        "tags": ["API keys"],
        "operationId": "deleteApiKey",
        "summary": "Revoke an API key",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/v1/auth/signin": {
      "post": {
        "tags": ["Auth"],
        "operationId": "signIn",
        "summary": "Exchange email and password for a JWT",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignInRequest"
              }
            }
          }
        },
        "security": [],
        "responses": {
          "200": {
            "description": "JWT, or a 2FA challenge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignInResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Token",
        "description": "API key from https://pocketalert.app/account/apikeys"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT from POST /v1/auth/signin"
      }
    },
    "parameters": {
      "Tid": {
        "name": "tid",
        "in": "path",
        "required": true,
        "description": "Resource identifier used by the API instead of a numeric id",
        "schema": {
          "type": "string",
          "examples": ["qm47b9pzxzxgqm47b9pzxzxgq"]
        }
      }
    },
    "headers": {
      "DailyLimit": {
        "description": "Daily message limit (absent on unlimited plans)",
        "schema": {
          "type": "integer"
        }
      },
      "DailyRemaining": {
        "description": "Messages left today",
        "schema": {
          "type": "integer"
        }
      },
      "DailyReset": {
        "description": "Unix time the counter resets",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Malformed or invalid payload",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, malformed or revoked credential",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Not available on the current plan, or plan limit reached",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource does not exist",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "The resource is in a state that does not allow the operation",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "DailyLimit": {
        "description": "Daily message limit reached; nothing was stored",
        "headers": {
          "X-PA-Daily-Limit": {
            "$ref": "#/components/headers/DailyLimit"
          },
          "X-PA-Daily-Remaining": {
            "$ref": "#/components/headers/DailyRemaining"
          },
          "X-PA-Daily-Reset": {
            "$ref": "#/components/headers/DailyReset"
          },
          "Retry-After": {
            "description": "Seconds until the limit resets",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/DailyLimitError"
            }
          }
        }
      },
      "ServerError": {
        "description": "Server error; also returned for missing resources with `record not found`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string",
            "examples": ["Title and message are required"]
          },
          "details": {
            "type": "string"
          }
        }
      },
      "DailyLimitError": {
        "type": "object",
        "required": ["error", "limit", "used", "resets_at"],
        "properties": {
          "error": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "examples": [50]
          },
          "used": {
            "type": "integer",
            "examples": [50]
          },
          "resets_at": {
            "type": "string",
            "format": "date-time"
          },
          "upgrade_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Success": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "string",
            "const": "success"
          }
        }
      },
      "DisplayTime": {
        "type": "string",
        "description": "Timestamp rendered as `DD.MM.YYYY HH:MM:SS` in the account timezone (not ISO 8601).",
        "pattern": "^\\d{2}\\.\\d{2}\\.\\d{4} \\d{2}:\\d{2}:\\d{2}$",
        "examples": ["04.01.2025 09:12:08"]
      },
      "Level": {
        "description": "Delivery level as a name or an integer. Aliases are accepted too: `min` = silent, `normal` = default, `max`/`urgent` = critical. `critical` bypasses Do Not Disturb and is a paid feature; free plans get `high`.",
        "oneOf": [
          {
            "type": "string",
            "enum": ["silent", "low", "default", "high", "critical"]
          },
          {
            "type": "integer",
            "minimum": -2,
            "maximum": 2,
            "description": "-2 silent, -1 low, 0 default, 1 high, 2 critical"
          }
        ],
        "examples": ["high"]
      },
      "Priority": {
        "type": "integer",
        "minimum": -2,
        "maximum": 2,
        "description": "Resolved level: -2 silent, -1 low, 0 default, 1 high, 2 critical"
      },
      "Action": {
        "type": "object",
        "description": "Notification action button (paid plans; silently dropped on free plans).",
        "required": ["type", "label", "value"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["view", "http", "copy"],
            "description": "`view` opens a URL, `http` fires a background request, `copy` copies text"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "examples": ["Open dashboard"]
          },
          "value": {
            "type": "string",
            "minLength": 1,
            "description": "`view`: an http(s) URL. `http`: a JSON string `{\"url\": ..., \"method\": ..., \"headers\": {...}, \"body\": ...}`. `copy`: literal text.",
            "examples": ["https://status.example.com"]
          }
        }
      },
      "Attachment": {
        "type": "object",
        "required": ["tid", "file_name", "content_type", "file_size"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "file_name": {
            "type": "string"
          },
          "content_type": {
            "type": "string",
            "examples": ["image/png"]
          },
          "file_size": {
            "type": "integer"
          },
          "link": {
            "type": "string",
            "format": "uri",
            "description": "Returned when reading messages"
          }
        }
      },
      "MessageCreate": {
        "type": "object",
        "required": ["title", "message"],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "examples": ["Deploy finished"]
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "examples": ["v1.4.2 is live"]
          },
          "application_id": {
            "type": "string",
            "description": "Application TID"
          },
          "device_id": {
            "type": "string",
            "description": "Device TID, or `all`. Omit to reach every device."
          },
          "level": {
            "$ref": "#/components/schemas/Level"
          },
          "actions": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/Action"
            }
          },
          "send_at": {
            "description": "Deliver later (paid plans): RFC 3339, Unix seconds, or `YYYY-MM-DD HH:MM` in the account timezone. At most 30 days ahead. Mutually exclusive with `delay`.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ],
            "examples": ["2026-10-01T09:00:00Z"]
          },
          "delay": {
            "type": "string",
            "description": "Deliver after a relative delay (paid plans): `30m`, `2h`, `1d`, or bare seconds.",
            "examples": ["30m"]
          },
          "image": {
            "type": "string",
            "description": "Image attachment (paid plans): an http(s) URL to download, a data URL, or base64."
          }
        }
      },
      "MessageCreateMultipart": {
        "type": "object",
        "required": ["title", "message"],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1
          },
          "message": {
            "type": "string",
            "minLength": 1
          },
          "application_id": {
            "type": "string"
          },
          "device_id": {
            "type": "string"
          },
          "level": {
            "type": "string",
            "description": "Level name or integer as text"
          },
          "actions": {
            "type": "string",
            "description": "JSON-encoded array of Action"
          },
          "send_at": {
            "type": "string"
          },
          "delay": {
            "type": "string"
          },
          "image": {
            "type": "string",
            "format": "binary",
            "description": "Image file (paid plans), max 10 MB"
          }
        }
      },
      "SentMessage": {
        "type": "object",
        "description": "Message accepted for immediate delivery.",
        "required": ["tid", "title", "message", "priority", "created_at"],
        "properties": {
          "tid": {
            "type": "string",
            "examples": ["zvtfxzk55fpqugz7ueslmse2a"]
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "priority": {
            "$ref": "#/components/schemas/Priority"
          },
          "application": {
            "type": "string",
            "description": "Application name, when one was set"
          },
          "device": {
            "type": "string",
            "description": "Device name, when one device was targeted"
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Action"
            }
          },
          "attachment": {
            "$ref": "#/components/schemas/Attachment"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "ScheduledMessageCreated": {
        "type": "object",
        "description": "Message stored for delayed delivery (returned when `send_at` or `delay` is in the future).",
        "required": [
          "tid",
          "scheduled",
          "status",
          "title",
          "message",
          "priority",
          "deliver_at",
          "deliver_at_utc",
          "tz"
        ],
        "properties": {
          "tid": {
            "type": "string"
          },
          "scheduled": {
            "type": "boolean",
            "const": true
          },
          "status": {
            "type": "string",
            "enum": ["pending"]
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "priority": {
            "$ref": "#/components/schemas/Priority"
          },
          "deliver_at": {
            "$ref": "#/components/schemas/DisplayTime"
          },
          "deliver_at_utc": {
            "type": "string",
            "format": "date-time"
          },
          "tz": {
            "type": "string",
            "examples": ["Europe/Berlin"]
          },
          "application": {
            "type": "string"
          },
          "device": {
            "type": "string"
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Action"
            }
          },
          "attachment": {
            "$ref": "#/components/schemas/Attachment"
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "tid",
          "title",
          "message",
          "application",
          "device",
          "is_read",
          "priority",
          "was_scheduled",
          "created_at"
        ],
        "properties": {
          "tid": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "application": {
            "type": "string",
            "description": "Application name, empty when none"
          },
          "device": {
            "type": "string",
            "description": "Device name, `All devices`, or empty"
          },
          "is_read": {
            "type": "boolean"
          },
          "priority": {
            "$ref": "#/components/schemas/Priority"
          },
          "was_scheduled": {
            "type": "boolean"
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Action"
            }
          },
          "attachment": {
            "$ref": "#/components/schemas/Attachment"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "MessagePage": {
        "type": "object",
        "required": ["data", "meta"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "meta": {
            "type": "object",
            "required": ["total", "has_more", "next_offset"],
            "properties": {
              "total": {
                "type": "integer"
              },
              "has_more": {
                "type": "boolean"
              },
              "next_offset": {
                "type": "integer"
              }
            }
          }
        }
      },
      "MessageStat": {
        "type": "object",
        "required": ["date", "count"],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "examples": ["2026-09-20"]
          },
          "count": {
            "type": "integer",
            "examples": [42]
          }
        }
      },
      "MessageUsage": {
        "type": "object",
        "required": ["used", "limit", "unlimited", "rejected", "resets_at"],
        "properties": {
          "used": {
            "type": "integer",
            "description": "Messages accepted today (UTC day)"
          },
          "limit": {
            "type": ["integer", "null"],
            "description": "Daily limit; null when unlimited"
          },
          "unlimited": {
            "type": "boolean"
          },
          "rejected": {
            "type": "integer",
            "description": "Requests rejected today by the limit"
          },
          "resets_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MessageUpdate": {
        "type": "object",
        "properties": {
          "is_read": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "ScheduledMessage": {
        "type": "object",
        "required": [
          "tid",
          "title",
          "message",
          "priority",
          "status",
          "deliver_at",
          "deliver_at_utc",
          "tz",
          "application",
          "device",
          "created_at"
        ],
        "properties": {
          "tid": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "priority": {
            "$ref": "#/components/schemas/Priority"
          },
          "status": {
            "$ref": "#/components/schemas/ScheduledStatus"
          },
          "deliver_at": {
            "$ref": "#/components/schemas/DisplayTime"
          },
          "deliver_at_utc": {
            "type": "string",
            "format": "date-time"
          },
          "tz": {
            "type": "string"
          },
          "application": {
            "type": "string"
          },
          "device": {
            "type": "string"
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Action"
            }
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "ScheduledStatus": {
        "type": "string",
        "enum": ["pending", "sending", "sent", "canceled", "failed"]
      },
      "ScheduledCancelResult": {
        "type": "object",
        "required": ["message"],
        "properties": {
          "message": {
            "type": "string",
            "examples": ["Scheduled message canceled"]
          }
        }
      },
      "Application": {
        "type": "object",
        "required": ["tid", "name", "color", "is_active", "created_at"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "examples": ["#FF5733"]
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "ApplicationInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "examples": ["Production API"]
          },
          "description": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "description": "Hex color",
            "examples": ["#FF5733"]
          },
          "icon": {
            "type": "string"
          },
          "default_level": {
            "type": "integer",
            "minimum": -2,
            "maximum": 2,
            "description": "Level used when a message sets none. -2 silent, -1 low, 0 default, 1 high, 2 critical"
          },
          "is_active": {
            "type": "boolean"
          }
        }
      },
      "Device": {
        "type": "object",
        "required": ["tid", "serial_number", "name", "is_active", "created_at"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "serial_number": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "examples": ["Work iPhone"]
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "DeviceUpdate": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "examples": ["Work iPhone"]
          }
        }
      },
      "Webhook": {
        "type": "object",
        "required": ["tid", "name", "url", "application_tid", "device_tid", "message", "actions", "created_at"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "Slug of the inbound URL `https://p4a.me/wh/{url}`"
          },
          "application_tid": {
            "type": "string"
          },
          "device_tid": {
            "type": "string"
          },
          "message": {
            "type": "string",
            "description": "Template; `*` forwards the whole payload"
          },
          "actions": {
            "type": "string",
            "description": "JSON-encoded actions template, empty when none"
          },
          "default_level": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": -2,
                "maximum": 2,
                "description": "-2 silent, -1 low, 0 default, 1 high, 2 critical"
              },
              {
                "type": "null"
              }
            ],
            "description": "Returned by the single-webhook read"
          },
          "is_active": {
            "type": "boolean",
            "description": "Absent in the create response"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "WebhookInput": {
        "type": "object",
        "description": "Update replaces every field: send the full object, omitted fields are cleared.",
        "required": ["name", "message"],
        "properties": {
          "name": {
            "type": "string",
            "examples": ["Grafana"]
          },
          "message": {
            "type": "string",
            "description": "Template rendered from the incoming JSON. `*` outputs the whole payload; `%field.path%` extracts values.",
            "examples": ["%title%: %message%"]
          },
          "url": {
            "type": "string",
            "description": "Custom slug; generated when omitted on create"
          },
          "application_id": {
            "type": "string",
            "description": "Application TID"
          },
          "device_id": {
            "type": "string",
            "description": "Device TID or `all`"
          },
          "default_level": {
            "type": "integer",
            "minimum": -2,
            "maximum": 2,
            "description": "Create only. -2 silent, -1 low, 0 default, 1 high, 2 critical"
          },
          "actions": {
            "type": "string",
            "description": "JSON-encoded array of up to 3 Action; `label`/`value` may contain `%field.path%`"
          },
          "is_active": {
            "type": "boolean",
            "description": "Update only; omitted means false"
          }
        }
      },
      "WebhookRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "method": {
            "type": "string"
          },
          "source_ip": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "headers": {
            "type": ["object", "null"],
            "additionalProperties": {
              "type": "string"
            }
          },
          "body": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": ["success", "error"]
          },
          "error_code": {
            "type": "string"
          },
          "rendered_message": {
            "type": "string"
          },
          "message_tid": {
            "type": "string"
          },
          "priority": {
            "type": ["integer", "null"]
          },
          "duration_ms": {
            "type": "integer"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "WebhookHistory": {
        "type": "object",
        "required": ["requests", "total", "page", "per", "retention_days", "webhook"],
        "properties": {
          "requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookRequest"
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "per": {
            "type": "integer"
          },
          "retention_days": {
            "type": "integer",
            "description": "0 means unlimited"
          },
          "webhook": {
            "type": "object",
            "properties": {
              "tid": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "is_active": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": ["tid", "name", "token", "is_active", "created_at"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "token": {
            "type": "string",
            "description": "Plaintext API key"
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "ApiKeyCreated": {
        "type": "object",
        "required": ["tid", "name", "token"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "token": {
            "type": "string",
            "description": "Plaintext API key"
          }
        }
      },
      "FormField": {
        "type": "object",
        "required": ["id", "type", "label"],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "textarea",
              "email",
              "phone",
              "number",
              "url",
              "date",
              "dropdown",
              "radio",
              "checkboxes",
              "checkbox",
              "rating",
              "nps",
              "hidden",
              "heading",
              "paragraph",
              "divider"
            ]
          },
          "label": {
            "type": "string"
          },
          "placeholder": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "options": {
            "type": ["array", "null"],
            "items": {
              "type": "string"
            }
          },
          "param": {
            "type": "string",
            "description": "Hidden fields: URL query parameter to read"
          }
        }
      },
      "FormSettings": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "top_text": {
            "type": "string"
          },
          "bottom_text": {
            "type": "string"
          },
          "success_message": {
            "type": "string"
          },
          "closed_message": {
            "type": "string"
          },
          "background_color": {
            "type": "string"
          },
          "card_color": {
            "type": "string"
          },
          "text_color": {
            "type": "string"
          },
          "primary_color": {
            "type": "string"
          },
          "font_family": {
            "type": "string"
          },
          "font_size": {
            "type": "integer"
          },
          "font_weight": {
            "type": "integer"
          },
          "border_radius": {
            "type": "integer"
          },
          "hide_branding": {
            "type": "boolean",
            "description": "Paid plans only"
          },
          "submit": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "size": {
                "type": "string"
              }
            }
          }
        }
      },
      "Form": {
        "type": "object",
        "required": ["tid", "name", "is_active", "fields", "settings", "created_at"],
        "properties": {
          "tid": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "application_tid": {
            "type": "string"
          },
          "device_tid": {
            "type": "string"
          },
          "default_level": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": -2,
                "maximum": 2,
                "description": "-2 silent, -1 low, 0 default, 1 high, 2 critical"
              },
              {
                "type": "null"
              }
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormField"
            }
          },
          "settings": {
            "$ref": "#/components/schemas/FormSettings"
          },
          "push_title": {
            "type": "string"
          },
          "allowed_origins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "max_responses": {
            "type": "integer",
            "description": "0 means unlimited"
          },
          "closes_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "closed": {
            "type": "boolean"
          },
          "submissions_count": {
            "type": "integer"
          },
          "last_submission_at": {
            "type": "string",
            "description": "DisplayTime, empty when never submitted"
          },
          "created_at": {
            "$ref": "#/components/schemas/DisplayTime"
          }
        }
      },
      "FormInput": {
        "type": "object",
        "description": "Update replaces the whole definition.",
        "required": ["name", "fields"],
        "properties": {
          "name": {
            "type": "string"
          },
          "application_tid": {
            "type": "string"
          },
          "device_tid": {
            "type": "string"
          },
          "default_level": {
            "type": "integer",
            "minimum": -2,
            "maximum": 2,
            "description": "-2 silent, -1 low, 0 default, 1 high, 2 critical"
          },
          "is_active": {
            "type": "boolean"
          },
          "push_title": {
            "type": "string",
            "description": "Template with `{Field label}` tokens"
          },
          "allowed_origins": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "max_responses": {
            "type": "integer"
          },
          "closes_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormField"
            }
          },
          "settings": {
            "$ref": "#/components/schemas/FormSettings"
          }
        }
      },
      "SignInRequest": {
        "type": "object",
        "required": ["email", "password"],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "password": {
            "type": "string",
            "format": "password"
          },
          "captcha_token": {
            "type": "string",
            "description": "Cloudflare Turnstile token, when required"
          }
        }
      },
      "SignInResponse": {
        "oneOf": [
          {
            "type": "object",
            "required": ["token"],
            "properties": {
              "token": {
                "type": "string",
                "description": "JWT for `Authorization: Bearer`"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "avatar": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": ["two_factor_required", "challenge"],
            "properties": {
              "two_factor_required": {
                "type": "boolean",
                "const": true
              },
              "challenge": {
                "type": "string",
                "description": "Pass to POST /v1/auth/2fa/login"
              }
            }
          }
        ]
      }
    }
  }
}
