{
  "openapi": "3.1.0",
  "info": {
    "title": "shrink.site",
    "version": "1.0.0",
    "description": "Free URL shortener with custom short links and a simple API. Shorten a long URL without signing up.\n\nData notice: all requests to this service are recorded and kept indefinitely, including full request and response bodies, headers, IP address, and connection fingerprints. Using this API means you acknowledge this. https://shrink.site/data-notice"
  },
  "servers": [
    {
      "url": "https://shrink.site"
    }
  ],
  "externalDocs": {
    "description": "API reference with request examples",
    "url": "https://shrink.site/docs"
  },
  "paths": {
    "/api/links": {
      "get": {
        "operationId": "createLinkGet",
        "summary": "Shorten a URL.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Public HTTP(S) destination.",
              "format": "uri",
              "example": "https://example.com"
            }
          },
          {
            "name": "alias",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Optional case-sensitive custom alias. Used aliases cannot be reused.",
              "pattern": "^[A-Za-z0-9_-]{3,64}$"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Response format.",
              "enum": [
                "json",
                "text"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLink"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "createLinkPost",
        "summary": "Shorten a URL.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Public HTTP(S) destination.",
                    "format": "uri",
                    "example": "https://example.com"
                  },
                  "alias": {
                    "type": "string",
                    "description": "Optional case-sensitive custom alias. Used aliases cannot be reused.",
                    "pattern": "^[A-Za-z0-9_-]{3,64}$"
                  },
                  "format": {
                    "type": "string",
                    "description": "Response format.",
                    "enum": [
                      "json",
                      "text"
                    ],
                    "default": "json"
                  }
                },
                "required": [
                  "url"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Public HTTP(S) destination.",
                    "format": "uri",
                    "example": "https://example.com"
                  },
                  "alias": {
                    "type": "string",
                    "description": "Optional case-sensitive custom alias. Used aliases cannot be reused.",
                    "pattern": "^[A-Za-z0-9_-]{3,64}$"
                  },
                  "format": {
                    "type": "string",
                    "description": "Response format.",
                    "enum": [
                      "json",
                      "text"
                    ],
                    "default": "json"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLink"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/s": {
      "get": {
        "operationId": "shortenTextGet",
        "summary": "da.gd-style plain-text short URL.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Public HTTP(S) destination.",
              "format": "uri",
              "example": "https://example.com"
            }
          },
          {
            "name": "alias",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Optional case-sensitive custom alias. Used aliases cannot be reused.",
              "pattern": "^[A-Za-z0-9_-]{3,64}$"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Response format.",
              "enum": [
                "json",
                "text"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "shortenTextPost",
        "summary": "da.gd-style plain-text short URL.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Public HTTP(S) destination.",
                    "format": "uri",
                    "example": "https://example.com"
                  },
                  "alias": {
                    "type": "string",
                    "description": "Optional case-sensitive custom alias. Used aliases cannot be reused.",
                    "pattern": "^[A-Za-z0-9_-]{3,64}$"
                  },
                  "format": {
                    "type": "string",
                    "description": "Response format.",
                    "enum": [
                      "json",
                      "text"
                    ],
                    "default": "json"
                  }
                },
                "required": [
                  "url"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Public HTTP(S) destination.",
                    "format": "uri",
                    "example": "https://example.com"
                  },
                  "alias": {
                    "type": "string",
                    "description": "Optional case-sensitive custom alias. Used aliases cannot be reused.",
                    "pattern": "^[A-Za-z0-9_-]{3,64}$"
                  },
                  "format": {
                    "type": "string",
                    "description": "Response format.",
                    "enum": [
                      "json",
                      "text"
                    ],
                    "default": "json"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/{id}": {
      "get": {
        "operationId": "followLink",
        "summary": "302 redirect to destination; supports HEAD.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Short link ID or alias."
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/links/{id}": {
      "get": {
        "operationId": "getLink",
        "summary": "Inspect the destination without redirecting.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Short link ID or alias."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/docs": {
      "get": {
        "operationId": "documentation",
        "summary": "Server-rendered HTML API reference.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/robots.txt": {
      "get": {
        "operationId": "robots",
        "summary": "Crawler access rules and sitemap location.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/sitemap.xml": {
      "get": {
        "operationId": "sitemap",
        "summary": "Public documentation sitemap.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "health",
        "summary": "Worker liveness (does not probe external dependencies).",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "agentGuide",
        "summary": "Plain-text agent usage guide.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Error": {
        "description": "The request failed. See error.code and error.message for details.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "CreatedLink": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "Public HTTP(S) destination.",
            "format": "uri",
            "example": "https://example.com"
          },
          "destination": {
            "type": "string",
            "description": "Public HTTP(S) destination.",
            "format": "uri",
            "example": "https://example.com"
          },
          "api_url": {
            "type": "string",
            "description": "Public HTTP(S) destination.",
            "format": "uri",
            "example": "https://example.com"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "title": {
            "type": "string"
          },
          "language": {
            "type": "string"
          }
        }
      }
    }
  }
}
