{
  "openapi": "3.1.0",
  "info": {
    "title": "Softlink API",
    "version": "1.0.0",
    "description": "Generate an account token at https://softl.ink/painel. Redirect codes are case-sensitive. You can view and modify only redirects that belong to the authenticated account."
  },
  "servers": [{"url": "https://softl.ink"}],
  "security": [{"accountToken": []}],
  "paths": {
    "/api/redirects": {
      "get": {
        "operationId": "listRedirects",
        "summary": "List redirects for the account",
        "parameters": [{"name": "cursor", "in": "query", "schema": {"type": "string"}, "description": "The next_cursor value from the previous response."}],
        "responses": {
          "200": {"description": "Up to 50 redirects and the cursor for the next page.", "content": {"application/json": {"schema": {
            "type": "object", "required": ["redirects", "next_cursor"],
            "properties": {"redirects": {"type": "array", "items": {"$ref": "#/components/schemas/Redirect"}}, "next_cursor": {"type": ["string", "null"]}}
          }}}},
          "400": {"$ref": "#/components/responses/Invalid"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      },
      "post": {
        "operationId": "createRedirect",
        "summary": "Create a redirect",
        "requestBody": {"required": true, "content": {"application/json": {"schema": {
          "type": "object", "required": ["code", "destination_url"],
          "properties": {"code": {"$ref": "#/components/schemas/Code"}, "destination_url": {"$ref": "#/components/schemas/Destination"}}
        }}}},
        "responses": {
          "201": {"$ref": "#/components/responses/Saved"},
          "200": {"$ref": "#/components/responses/Saved"},
          "400": {"$ref": "#/components/responses/Invalid"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "409": {"description": "The code is already reserved for a different destination or account."},
          "413": {"description": "The request body exceeds 256 KiB."},
          "415": {"description": "Send the request body as application/json."},
          "429": {"description": "The account has reached its monthly link creation limit or the request rate limit."},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      }
    },
    "/api/redirects/{code}": {
      "parameters": [{"name": "code", "in": "path", "required": true, "schema": {"$ref": "#/components/schemas/Code"}}],
      "get": {
        "operationId": "getRedirect",
        "summary": "Get a redirect",
        "responses": {
          "200": {"$ref": "#/components/responses/Saved"},
          "400": {"$ref": "#/components/responses/Invalid"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      },
      "put": {
        "operationId": "editRedirect",
        "summary": "Update a redirect destination",
        "requestBody": {"required": true, "content": {"application/json": {"schema": {
          "type": "object", "required": ["destination_url"],
          "properties": {"destination_url": {"$ref": "#/components/schemas/Destination"}}
        }}}},
        "responses": {
          "200": {"$ref": "#/components/responses/Saved"},
          "400": {"$ref": "#/components/responses/Invalid"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "409": {"description": "The redirect was updated by another request."},
          "403": {"description": "Changing the redirect destination requires an active Pro plan when billing is enabled."},
          "413": {"description": "The request body exceeds 256 KiB."},
          "415": {"description": "Send the request body as application/json."},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      },
      "delete": {
        "operationId": "deleteRedirect",
        "summary": "Delete a redirect",
        "description": "The public URL stops redirecting and its code remains reserved.",
        "responses": {
          "200": {"description": "The redirect was deleted."},
          "400": {"$ref": "#/components/responses/Invalid"},
          "401": {"$ref": "#/components/responses/Unauthorized"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"description": "The request rate limit was exceeded."},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      }
    }
  },
  "components": {
    "securitySchemes": {"accountToken": {"type": "http", "scheme": "bearer"}},
    "schemas": {
      "Code": {"type": "string", "pattern": "^[A-Za-z0-9._~-]{1,128}$", "description": "Public redirect code. Some service paths are reserved."},
      "Destination": {"type": "string", "format": "uri", "maxLength": 2048, "description": "HTTP or HTTPS URL. Use IDNA for domain names and percent-encode non-ASCII characters elsewhere in the URL."},
      "Redirect": {"type": "object", "required": ["code", "url", "destination_url"], "properties": {
        "code": {"$ref": "#/components/schemas/Code"}, "url": {"type": "string", "format": "uri"}, "destination_url": {"$ref": "#/components/schemas/Destination"}
      }}
    },
    "responses": {
      "Saved": {"description": "Redirect details.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Redirect"}}}},
      "Unauthorized": {"description": "The account token is missing or invalid."},
      "NotFound": {"description": "The redirect is unavailable to this account."},
      "Invalid": {"description": "Invalid request data."},
      "Unavailable": {"description": "The service is temporarily unavailable."}
    }
  }
}
