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

# Create URL redirect

> <Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Adds a 301 redirect to the app's published site.

Use it to keep old links working after you rename or remove a page. The rule takes effect on the published site once this call returns.

Base44 also tries to drop any cached copy of the source path so visitors get the redirect straight away, but that step can fail without failing the call. When it does, the source URL keeps serving its cached page with a 200 instead of the new 301 until the cache refreshes on its own. A `prefix` rule affects child paths too, and each one has its own cached copy. Base44 drops the copies it knows about, and any it doesn't keep serving their old page until that cache expires.

A rule is rejected when:

- Its source is a path the redirect layer never sees, which covers `/sitemap.xml`, `/robots.txt`, `/favicon.ico`, `/manifest.json`, `/link_preview.png`, `/llms.txt`, `/.well-known/*`, and the app's auth paths
- Its source and target are the same
- It's a `prefix` rule starting at `/`
- It overlaps another rule, so a `prefix` rule at `/docs` blocks a `single` rule at `/docs/intro`
- It would make a visitor follow two redirects in a row, which happens when an internal target matches another rule's source

An app can hold up to 50 rules, and the 51st is rejected.

URL redirects are part of custom domains, so creating, updating and deleting one needs a workspace whose plan includes them. Listing them doesn't.

<Warning>The response includes fields beyond the ones documented here. Don't rely on undocumented response fields, as they can change at any time.</Warning>



## OpenAPI

````yaml /developers/references/app-management/app-management-openapi.json post /api/apps/{app_id}/url-redirects
openapi: 3.1.0
info:
  title: Base44 App Management API
  version: 1.0.0
servers:
  - url: https://app.base44.com
security:
  - ApiKeyAuth: []
paths:
  /api/apps/{app_id}/url-redirects:
    post:
      summary: Create URL redirect
      description: >-
        <Info>This API is in beta. Endpoints, fields, and behavior may still
        change, so avoid depending on it in production.</Info>


        Adds a 301 redirect to the app's published site.


        Use it to keep old links working after you rename or remove a page. The
        rule takes effect on the published site once this call returns.


        Base44 also tries to drop any cached copy of the source path so visitors
        get the redirect straight away, but that step can fail without failing
        the call. When it does, the source URL keeps serving its cached page
        with a 200 instead of the new 301 until the cache refreshes on its own.
        A `prefix` rule affects child paths too, and each one has its own cached
        copy. Base44 drops the copies it knows about, and any it doesn't keep
        serving their old page until that cache expires.


        A rule is rejected when:


        - Its source is a path the redirect layer never sees, which covers
        `/sitemap.xml`, `/robots.txt`, `/favicon.ico`, `/manifest.json`,
        `/link_preview.png`, `/llms.txt`, `/.well-known/*`, and the app's auth
        paths

        - Its source and target are the same

        - It's a `prefix` rule starting at `/`

        - It overlaps another rule, so a `prefix` rule at `/docs` blocks a
        `single` rule at `/docs/intro`

        - It would make a visitor follow two redirects in a row, which happens
        when an internal target matches another rule's source


        An app can hold up to 50 rules, and the 51st is rejected.


        URL redirects are part of custom domains, so creating, updating and
        deleting one needs a workspace whose plan includes them. Listing them
        doesn't.


        <Warning>The response includes fields beyond the ones documented here.
        Don't rely on undocumented response fields, as they can change at any
        time.</Warning>
      operationId: create_url_redirect_api_apps__app_id__url_redirects_post
      parameters:
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            description: ID of the app whose URL redirects you want to work with.
            title: App Id
          description: ID of the app whose URL redirects you want to work with.
          example: 6820f3a4e7b91d003c45a1f2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UrlRedirectPayload'
      responses:
        '200':
          description: The redirect that was created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UrlRedirectResource'
        '400':
          description: The app already has 50 URL redirects.
        '401':
          description: Missing or invalid credentials.
        '402':
          description: This workspace's plan doesn't include custom domains.
        '403':
          description: >-
            You don't have access to this app, or you used a workspace API key.
            These endpoints take a personal API key.
        '404':
          description: App not found.
        '422':
          description: >-
            The request body is invalid, or the redirect breaks one of the rules
            above. The message names what failed.
components:
  schemas:
    UrlRedirectPayload:
      properties:
        source_path:
          type: string
          maxLength: 512
          minLength: 1
          title: Source Path
          description: >-
            Path visitors request, starting with `/` and carrying no query
            string or fragment. Base44 strips a trailing slash and decodes
            percent-escapes before storing it, so `/old/` and `/%6Fld` are the
            same rule.
          example: /old-pricing
        target_path:
          type: string
          maxLength: 512
          minLength: 1
          title: Target Path
          description: >-
            Where to send the visitor. Either an internal path starting with
            `/`, normalized the same way as `source_path`, or an absolute
            `https://` URL on another site, kept as you sent it. Send it without
            a query string or fragment. The visitor's own query string is
            carried over to the destination, so `/old?utm=x` lands on
            `/new?utm=x`.
          example: /pricing
        match_type:
          $ref: '#/components/schemas/UrlRedirectMatchType'
          description: >-
            Use `single` to redirect that exact path, or `prefix` to redirect it
            and everything under it, keeping the remainder of the path. Defaults
            to `single`, so omitting it on an update turns an existing `prefix`
            rule into a `single` one and its child paths stop redirecting.
          default: single
          example: single
      additionalProperties: false
      type: object
      required:
        - source_path
        - target_path
      title: UrlRedirectPayload
    UrlRedirectResource:
      properties:
        id:
          type: string
          title: Id
          description: >-
            ID of the redirect. Pass it as `redirect_id` to [Update URL
            redirect](/api-reference/update-url-redirect) and [Delete URL
            redirect](/api-reference/delete-url-redirect).
          example: 68c2d1e5f3b8a4216e9b5583
        source_path:
          type: string
          title: Source Path
          description: >-
            The path visitors request, normalized with no trailing slash and
            percent-escapes decoded.
          example: /old-pricing
        target_path:
          type: string
          title: Target Path
          description: >-
            Where the visitor is sent. Either an internal path, normalized the
            same way as `source_path`, or an absolute `https://` URL on another
            site, kept exactly as you sent it.
          example: /pricing
        match_type:
          $ref: '#/components/schemas/UrlRedirectMatchType'
          description: >-
            How the rule matches. A `single` rule redirects that exact path, and
            a `prefix` rule redirects it and everything under it, keeping the
            remainder of the path.
          example: single
      type: object
      required:
        - id
        - source_path
        - target_path
        - match_type
      title: UrlRedirectResource
      description: One 301 redirect rule on the app's published site.
    UrlRedirectMatchType:
      type: string
      enum:
        - single
        - prefix
      title: UrlRedirectMatchType
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key
      description: Personal API key.

````