> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spoo.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Update URL

> Update an existing URL's properties.

Partially update a shortened URL. Only provided fields are modified; omitted
fields remain unchanged. Pass `null` to remove optional settings like
`password`, `max_clicks`, or `expire_after`.

**Authentication**: Required — you must own the URL.

**API Key Scope**: `urls:manage` or `admin:all`

**Rate Limits**: 120/min, 2,000/day

**Updatable Fields**: `long_url`, `alias`, `password`, `block_bots`,
`max_clicks`, `expire_after`, `private_stats`, `status`

**Notes**:
- Setting `max_clicks` to `0` or `null` removes the click limit
- Changing the `alias` checks availability and may fail with 409 Conflict
- The `url_id` is the MongoDB ObjectId, not the alias



## OpenAPI

````yaml /openapi-v1.json patch /api/v1/urls/{url_id}
openapi: 3.1.0
info:
  title: spoo.me
  description: >-
    REST API for spoo.me — free and open-source URL shortening service serving
    400k+ redirects/day.


    Authenticate using either:

    - **API Key**: `Authorization: Bearer spoo_<your_key>`

    - **JWT Token**: `Authorization: Bearer <jwt>` (obtained via /auth/login)

    - **Session Cookie**: `access_token` cookie (set automatically on login)
  contact:
    name: spoo.me
    url: https://spoo.me/contact
    email: support@spoo.me
  license:
    name: AGPL-3.0
    url: https://github.com/spoo-me/spoo/blob/main/LICENSE
  version: 1.0.0
servers:
  - url: https://spoo.me
    description: Production
security:
  - ApiKeyAuth: []
  - JWTAuth: []
tags:
  - name: URL Shortening
    description: Create new shortened URLs
  - name: Link Management
    description: List, update, and delete your shortened URLs
  - name: Statistics
    description: Click analytics and data export
  - name: API Keys
    description: Create and manage API keys for programmatic access
  - name: Authentication
    description: Login, register, password management, and email verification
  - name: OAuth
    description: OAuth provider login, linking, and unlinking
  - name: System
    description: Health checks and server metrics
paths:
  /api/v1/urls/{url_id}:
    patch:
      tags:
        - Link Management
      summary: Update URL
      description: >-
        Update an existing URL's properties.


        Partially update a shortened URL. Only provided fields are modified;
        omitted

        fields remain unchanged. Pass `null` to remove optional settings like

        `password`, `max_clicks`, or `expire_after`.


        **Authentication**: Required — you must own the URL.


        **API Key Scope**: `urls:manage` or `admin:all`


        **Rate Limits**: 120/min, 2,000/day


        **Updatable Fields**: `long_url`, `alias`, `password`, `block_bots`,

        `max_clicks`, `expire_after`, `private_stats`, `status`


        **Notes**:

        - Setting `max_clicks` to `0` or `null` removes the click limit

        - Changing the `alias` checks availability and may fail with 409
        Conflict

        - The `url_id` is the MongoDB ObjectId, not the alias
      operationId: updateUrl
      parameters:
        - name: url_id
          in: path
          required: true
          schema:
            type: string
            description: Unique identifier of the URL
            title: Url Id
          description: Unique identifier of the URL
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUrlRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateUrlResponse'
        '400':
          description: Bad Request — invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized — missing or invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden — insufficient permissions or scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflict — resource already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    UpdateUrlRequest:
      properties:
        long_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Long Url
          description: New destination URL. Must be a valid http:// or https:// URL.
          examples:
            - https://example.com/updated/url
        alias:
          anyOf:
            - type: string
            - type: 'null'
          title: Alias
          description: >-
            New custom short code. Pass `null` to keep existing. Must be unique
            and available.
          examples:
            - newlink
        password:
          anyOf:
            - type: string
            - type: 'null'
          title: Password
          description: New password. Pass `null` to remove password protection.
          examples:
            - newPass@456
        block_bots:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Block Bots
          description: Block known bot user agents. Pass `null` to keep existing setting.
        max_clicks:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Max Clicks
          description: New click limit. Pass `0` or `null` to remove the limit.
          examples:
            - 500
        expire_after:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Expire After
          description: >-
            Expiration time. ISO 8601 string (e.g. `2025-12-31T23:59:59Z`) or
            Unix epoch seconds (e.g. `1735689599`). Pass `null` to remove.
          examples:
            - '2025-12-31T23:59:59Z'
            - 1735689599
        private_stats:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Private Stats
          description: >-
            Make statistics private (only owner can view). Pass `null` to keep
            existing.
        status:
          anyOf:
            - type: string
              enum:
                - ACTIVE
                - INACTIVE
            - type: 'null'
          title: Status
          description: URL status. ACTIVE enables redirects, INACTIVE disables them.
          examples:
            - ACTIVE
      type: object
      title: UpdateUrlRequest
      description: |-
        Request body for partially updating an existing shortened URL.

        All fields are optional; only provided fields are updated.
        Pass ``max_clicks=0`` or ``max_clicks=null`` to remove the limit.
        Pass ``password=null`` (or omit) to remove password protection.
    UpdateUrlResponse:
      properties:
        id:
          type: string
          title: Id
          description: MongoDB ObjectId of the URL.
          examples:
            - 507f1f77bcf86cd799439011
        alias:
          anyOf:
            - type: string
            - type: 'null'
          title: Alias
          description: Short code.
          examples:
            - mylink
        long_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Long Url
          description: Destination URL.
          examples:
            - https://example.com/long/url
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
          description: URL status.
          examples:
            - ACTIVE
        password_set:
          type: boolean
          title: Password Set
          description: Whether the URL is password-protected.
        max_clicks:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Clicks
          description: Click limit, or null if unlimited.
          examples:
            - 100
        expire_after:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expire After
          description: Expiration as Unix timestamp, or null.
          examples:
            - 1735689599
        block_bots:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Block Bots
          description: Whether bot blocking is enabled.
        private_stats:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Private Stats
          description: Whether statistics are private.
        updated_at:
          type: integer
          title: Updated At
          description: Last update time as Unix timestamp.
          examples:
            - 1704067200
      type: object
      required:
        - id
        - password_set
        - updated_at
      title: UpdateUrlResponse
      description: >-
        Response body after a successful URL update (PATCH
        /api/v1/urls/{url_id}).
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
        error_code:
          type: string
          title: Error Code
        field:
          anyOf:
            - type: string
            - type: 'null'
          title: Field
        details:
          anyOf:
            - {}
            - type: 'null'
          title: Details
      type: object
      required:
        - error
        - error_code
      title: ErrorResponse
      description: Standard error JSON body produced by the AppError exception handler.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: spoo_<key>
      description: 'API key authentication. Pass your key as: `Bearer spoo_<your_key>`'
    JWTAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'JWT access token from /auth/login. Pass as: `Bearer <jwt_token>`'

````