{
  "openapi": "3.0.4",
  "info": {
    "title": "ShortenURL Public API",
    "description": "Create and manage short links programmatically. Authenticate every request with an API key from the developer portal: `Authorization: Bearer su_...`. Errors are RFC 9457 problem+json objects with a stable `code` member. Plan limits apply per client (requests per minute and links per calendar month, UTC).",
    "version": "v1"
  },
  "paths": {
    "/api/v1/links": {
      "post": {
        "tags": [
          "Links"
        ],
        "summary": "Create a short link.",
        "description": "Shortening a URL you already shortened (without alias/password/schedule) returns your existing\r\nlink with 200 and alreadyExisted=true, using no quota. Send an Idempotency-Key header (1-64\r\nprintable ASCII characters) to make retries safe: the same key with the same body replays the\r\noriginal response for 24 hours; the same key with a different body returns 422.\r\nResponse headers X-Quota-Limit / X-Quota-Remaining report the monthly link quota.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLinkRequestV1"
              }
            }
          }
        },
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLinkV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLinkV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLinkV1"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLinkV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLinkV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLinkV1"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Content",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "List your links, newest first (cursor pagination).",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1-100 (default 20).",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/LinkPageV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkPageV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkPageV1"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/links/{code}": {
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "Get one of your links.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^[a-zA-Z0-9]{3,16}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/LinkV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkV1"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Links"
        ],
        "summary": "Disable or re-enable one of your links.",
        "description": "Links taken down by the platform (abuse) can't be re-enabled through the API (409 link_locked).",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^[a-zA-Z0-9]{3,16}$",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateLinkRequestV1"
              }
            }
          }
        },
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/LinkV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkV1"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Links"
        ],
        "summary": "Delete one of your links.",
        "description": "The link stops redirecting immediately and disappears from your account. Its code is never reissued.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^[a-zA-Z0-9]{3,16}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/links/{code}/stats": {
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "Click statistics for one of your links.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^[a-zA-Z0-9]{3,16}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/LinkStatsV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkStatsV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkStatsV1"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/links/{code}/qr.{format}": {
      "get": {
        "tags": [
          "Links"
        ],
        "summary": "QR code (PNG or SVG) encoding one of your short links.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^[a-zA-Z0-9]{3,16}$",
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^(png|svg)$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/usage": {
      "get": {
        "tags": [
          "Usage"
        ],
        "summary": "Your plan, this month's link quota and the last 30 days of requests.",
        "responses": {
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/UsageV1"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageV1"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageV1"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateLinkRequestV1": {
        "required": [
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "maxLength": 2048,
            "minLength": 0,
            "type": "string",
            "description": "Destination URL (absolute http/https, max 2048 characters)."
          },
          "alias": {
            "maxLength": 16,
            "minLength": 0,
            "type": "string",
            "description": "Optional custom code (3-16 letters/digits). Requires a plan with custom aliases.",
            "nullable": true
          },
          "password": {
            "maxLength": 128,
            "minLength": 0,
            "type": "string",
            "description": "Optional visitor password (8-128 characters). Requires a plan with password protection. Never returned.",
            "nullable": true
          },
          "activatesAt": {
            "type": "string",
            "description": "Optional future instant (ISO 8601 with offset, e.g. 2026-12-01T09:00:00Z) before which the link won't redirect. Requires a plan with scheduling.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Create a short link."
      },
      "CreatedLinkV1": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "shortUrl": {
            "type": "string",
            "nullable": true
          },
          "originalUrl": {
            "type": "string",
            "nullable": true
          },
          "trackingUrl": {
            "type": "string",
            "nullable": true
          },
          "passwordProtected": {
            "type": "boolean"
          },
          "activatesAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "alreadyExisted": {
            "type": "boolean"
          }
        },
        "additionalProperties": false,
        "description": "Result of POST /api/v1/links. alreadyExisted = true means you had already shortened this exact URL; the existing link is returned and no quota is used."
      },
      "DailyCountV1": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "count": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "LinkPageV1": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkV1"
            },
            "nullable": true
          },
          "nextCursor": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A page of links, newest first. Pass nextCursor as ?cursor= to get the next page; null means no more pages."
      },
      "LinkStatsV1": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "shortUrl": {
            "type": "string",
            "nullable": true
          },
          "totalClicks": {
            "type": "integer",
            "format": "int32"
          },
          "clicksByDay": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyCountV1"
            },
            "nullable": true
          },
          "topReferrers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedCountV1"
            },
            "nullable": true
          },
          "topCountries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedCountV1"
            },
            "nullable": true
          },
          "devices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedCountV1"
            },
            "nullable": true
          },
          "browsers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedCountV1"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Click statistics for one link (daily series covers the last 30 days, UTC)."
      },
      "LinkV1": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "shortUrl": {
            "type": "string",
            "nullable": true
          },
          "originalUrl": {
            "type": "string",
            "nullable": true
          },
          "trackingUrl": {
            "type": "string",
            "nullable": true
          },
          "isActive": {
            "type": "boolean"
          },
          "disabledByPlatform": {
            "type": "boolean"
          },
          "passwordProtected": {
            "type": "boolean"
          },
          "activatesAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "clickCount": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A short link owned by the calling client."
      },
      "NamedCountV1": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "count": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "PlanFeaturesV1": {
        "type": "object",
        "properties": {
          "customAlias": {
            "type": "boolean"
          },
          "passwordProtection": {
            "type": "boolean"
          },
          "scheduling": {
            "type": "boolean"
          },
          "qrCodes": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PlanV1": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "monthlyLinkQuota": {
            "type": "integer",
            "format": "int32"
          },
          "requestsPerMinute": {
            "type": "integer",
            "format": "int32"
          },
          "features": {
            "$ref": "#/components/schemas/PlanFeaturesV1"
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "UpdateLinkRequestV1": {
        "required": [
          "isActive"
        ],
        "type": "object",
        "properties": {
          "isActive": {
            "type": "boolean",
            "description": "false disables the link (visitors get 404); true re-enables a link you disabled."
          }
        },
        "additionalProperties": false,
        "description": "Enable or disable one of your links."
      },
      "UsageDayV1": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "requests": {
            "type": "integer",
            "format": "int32"
          },
          "linksCreated": {
            "type": "integer",
            "format": "int32"
          },
          "rejected": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "UsageV1": {
        "type": "object",
        "properties": {
          "plan": {
            "$ref": "#/components/schemas/PlanV1"
          },
          "periodStart": {
            "type": "string",
            "format": "date-time"
          },
          "periodEnd": {
            "type": "string",
            "format": "date-time"
          },
          "linksCreatedThisPeriod": {
            "type": "integer",
            "format": "int32"
          },
          "linksRemaining": {
            "type": "integer",
            "format": "int32"
          },
          "last30Days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UsageDayV1"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Your plan, this month's link quota and recent request volume."
      },
      "ValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "nullable": true
          }
        },
        "additionalProperties": { }
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "description": "API key from the developer portal.",
        "scheme": "bearer",
        "bearerFormat": "su_{prefix}_{secret}"
      }
    }
  },
  "security": [
    {
      "bearer": [ ]
    }
  ]
}