Shlink Redirect rules API

Handle dynamic rule-based redirects

Operations 2

GET /rest/v{version}/short-urls/{shortCode}/redirect-rules List short URL redirect rules #
POST /rest/v{version}/short-urls/{shortCode}/redirect-rules Set short URL redirect rules #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/shlink:shlink-redirect-rules-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

shlink-redirect-rules-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Shlink Redirect rules API
  version: '3.0'
  description: 'Operations tagged Redirect rules across 3 of this provider''s published API definitions: shlink-openapi-v5.1.4.json, shlink-openapi-v5.1.0.json, shlink-openapi.json. Each path carries the servers of the definition it was published in.'
servers:
- url: '{scheme}://{host}'
  variables:
    scheme:
      enum:
      - https
      - http
      default: https
    host:
      default: ''
tags:
- name: Redirect Rules
  description: Handle dynamic rule-based redirects
paths:
  /rest/v{version}/short-urls/{shortCode}/redirect-rules:
    get:
      tags:
      - Redirect Rules
      summary: List short URL redirect rules
      description: Returns the list of redirect rules for a short URL.
      operationId: listShortUrlRedirectRules
      parameters:
      - name: version
        in: path
        description: The API version to be consumed
        required: true
        schema:
          enum:
          - '3'
          - '2'
          - '1'
          type: string
      - name: shortCode
        in: path
        description: The short code for the short URL.
        required: true
        schema:
          type: string
      - name: domain
        in: query
        description: The domain in which the short code should be searched for.
        required: false
        schema:
          type: string
      responses:
        '200':
          description: The list of rules
          content:
            application/json:
              schema:
                required:
                - defaultLongUrl
                - redirectRules
                type: object
                properties:
                  defaultLongUrl:
                    type: string
                  redirectRules:
                    type: array
                    items:
                      required:
                      - priority
                      type: object
                      allOf:
                      - required:
                        - longUrl
                        - conditions
                        type: object
                        properties:
                          longUrl:
                            type: string
                            description: Long URL to redirect to when this condition matches
                          conditions:
                            type: array
                            items:
                              required:
                              - type
                              - matchKey
                              - matchValue
                              type: object
                              properties:
                                type:
                                  enum:
                                  - device
                                  - language
                                  - query-param
                                  - any-value-query-param
                                  - valueless-query-param
                                  - ip-address
                                  - geolocation-country-code
                                  - geolocation-city-name
                                  - before-date
                                  - after-date
                                  - browser
                                  type: string
                                  description: The type of the condition, which will determine the logic used to match it
                                matchKey:
                                  type:
                                  - string
                                  - 'null'
                                matchValue:
                                  type:
                                  - string
                                  - 'null'
                            description: List of conditions that need to match in order to consider this rule matches
                      properties:
                        priority:
                          type: number
                          description: Order in which attempting to match the rule. Lower goes first
              example:
                defaultLongUrl: https://example.com
                redirectRules:
                - longUrl: https://example.com/android-en-us
                  priority: 1
                  conditions:
                  - type: device
                    matchValue: android
                    matchKey: null
                  - type: language
                    matchValue: en-US
                    matchKey: null
                - longUrl: https://example.com/fr
                  priority: 2
                  conditions:
                  - type: language
                    matchValue: fr
                    matchKey: null
                - longUrl: https://example.com/query-foo-bar-hello-world
                  priority: 3
                  conditions:
                  - type: query-param
                    matchKey: foo
                    matchValue: bar
                  - type: query-param
                    matchKey: hello
                    matchValue: world
        '404':
          description: No URL was found for provided short code.
          content:
            application/problem+json:
              schema:
                allOf:
                - required:
                  - type
                  - title
                  - detail
                  - status
                  type: object
                  properties:
                    type:
                      type: string
                      description: A machine unique code
                    title:
                      type: string
                      description: A unique title
                    detail:
                      type: string
                      description: A human-friendly error description
                    status:
                      type: number
                      description: HTTP response status code
                - required:
                  - shortCode
                  type: object
                  properties:
                    shortCode:
                      type: string
                      description: The short code with which we tried to find the short URL
                    domain:
                      type: string
                      description: The domain with which we tried to find the short URL
              examples:
                Short URL not found:
                  value:
                    detail: No URL found with short code "abc123"
                    title: Short URL not found
                    type: https://shlink.io/api/error/short-url-not-found
                    status: 404
                    shortCode: abc123
        default:
          description: Unexpected error.
          content:
            application/problem+json:
              schema:
                required:
                - type
                - title
                - detail
                - status
                type: object
                properties:
                  type:
                    type: string
                    description: A machine unique code
                  title:
                    type: string
                    description: A unique title
                  detail:
                    type: string
                    description: A human-friendly error description
                  status:
                    type: number
                    description: HTTP response status code
      security:
      - ApiKey: []
    post:
      tags:
      - Redirect Rules
      summary: Set short URL redirect rules
      description: Sets redirect rules for a short URL, with priorities matching the order in which they are provided.
      operationId: setShortUrlRedirectRules
      parameters:
      - name: version
        in: path
        description: The API version to be consumed
        required: true
        schema:
          enum:
          - '3'
          - '2'
          - '1'
          type: string
      - name: shortCode
        in: path
        description: The short code for the short URL.
        required: true
        schema:
          type: string
      - name: domain
        in: query
        description: The domain in which the short code should be searched for.
        required: false
        schema:
          type: string
      requestBody:
        description: Request body.
        content:
          application/json:
            schema:
              type: object
              properties:
                redirectRules:
                  type: array
                  items:
                    required:
                    - longUrl
                    - conditions
                    type: object
                    properties:
                      longUrl:
                        type: string
                        description: Long URL to redirect to when this condition matches
                      conditions:
                        type: array
                        items:
                          required:
                          - type
                          - matchKey
                          - matchValue
                          type: object
                          properties:
                            type:
                              enum:
                              - device
                              - language
                              - query-param
                              - any-value-query-param
                              - valueless-query-param
                              - ip-address
                              - geolocation-country-code
                              - geolocation-city-name
                              - before-date
                              - after-date
                              - browser
                              type: string
                              description: The type of the condition, which will determine the logic used to match it
                            matchKey:
                              type:
                              - string
                              - 'null'
                            matchValue:
                              type:
                              - string
                              - 'null'
                        description: List of conditions that need to match in order to consider this rule matches
            example:
              redirectRules:
              - longUrl: https://example.com/android-en-us
                conditions:
                - type: device
                  matchValue: android
                  matchKey: null
                - type: language
                  matchValue: en-US
                  matchKey: null
              - longUrl: https://example.com/fr
                conditions:
                - type: language
                  matchValue: fr
                  matchKey: null
              - longUrl: https://example.com/query-foo-bar-hello-world
                conditions:
                - type: query-param
                  matchKey: foo
                  matchValue: bar
                - type: query-param
                  matchKey: hello
                  matchValue: world
        required: true
      responses:
        '200':
          description: The list of rules
          content:
            application/json:
              schema:
                required:
                - defaultLongUrl
                - redirectRules
                type: object
                properties:
                  defaultLongUrl:
                    type: string
                  redirectRules:
                    type: array
                    items:
                      required:
                      - priority
                      type: object
                      allOf:
                      - required:
                        - longUrl
                        - conditions
                        type: object
                        properties:
                          longUrl:
                            type: string
                            description: Long URL to redirect to when this condition matches
                          conditions:
                            type: array
                            items:
                              required:
                              - type
                              - matchKey
                              - matchValue
                              type: object
                              properties:
                                type:
                                  enum:
                                  - device
                                  - language
                                  - query-param
                                  - any-value-query-param
                                  - valueless-query-param
                                  - ip-address
                                  - geolocation-country-code
                                  - geolocation-city-name
                                  - before-date
                                  - after-date
                                  - browser
                                  type: string
                                  description: The type of the condition, which will determine the logic used to match it
                                matchKey:
                                  type:
                                  - string
                                  - 'null'
                                matchValue:
                                  type:
                                  - string
                                  - 'null'
                            description: List of conditions that need to match in order to consider this rule matches
                      properties:
                        priority:
                          type: number
                          description: Order in which attempting to match the rule. Lower goes first
              example:
                defaultLongUrl: https://example.com
                redirectRules:
                - longUrl: https://example.com/android-en-us
                  priority: 1
                  conditions:
                  - type: device
                    matchValue: android
                    matchKey: null
                  - type: language
                    matchValue: en-US
                    matchKey: null
                - longUrl: https://example.com/fr
                  priority: 2
                  conditions:
                  - type: language
                    matchValue: fr
                    matchKey: null
                - longUrl: https://example.com/query-foo-bar-hello-world
                  priority: 3
                  conditions:
                  - type: query-param
                    matchKey: foo
                    matchValue: bar
                  - type: query-param
                    matchKey: hello
                    matchValue: world
        '404':
          description: No URL was found for provided short code.
          content:
            application/problem+json:
              schema:
                allOf:
                - required:
                  - type
                  - title
                  - detail
                  - status
                  type: object
                  properties:
                    type:
                      type: string
                      description: A machine unique code
                    title:
                      type: string
                      description: A unique title
                    detail:
                      type: string
                      description: A human-friendly error description
                    status:
                      type: number
                      description: HTTP response status code
                - required:
                  - shortCode
                  type: object
                  properties:
                    shortCode:
                      type: string
                      description: The short code with which we tried to find the short URL
                    domain:
                      type: string
                      description: The domain with which we tried to find the short URL
              examples:
                Short URL not found:
                  value:
                    detail: No URL found with short code "abc123"
                    title: Short URL not found
                    type: https://shlink.io/api/error/short-url-not-found
                    status: 404
                    shortCode: abc123
        default:
          description: Unexpected error.
          content:
            application/problem+json:
              schema:
                required:
                - type
                - title
                - detail
                - status
                type: object
                properties:
                  type:
                    type: string
                    description: A machine unique code
                  title:
                    type: string
                    description: A unique title
                  detail:
                    type: string
                    description: A human-friendly error description
                  status:
                    type: number
                    description: HTTP response status code
      security:
      - ApiKey: []
    servers:
    - url: '{scheme}://{host}'
      variables:
        scheme:
          enum:
          - https
          - http
          default: https
        host:
          default: ''
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: A valid shlink API key
      name: X-Api-Key
      in: header
externalDocs:
  description: Find more info on how to start using this API here
  url: https://shlink.io/documentation/api-docs
x-refined-from:
- shlink-openapi-v5.1.4.json
- shlink-openapi-v5.1.0.json
- shlink-openapi.json