> ## 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 is best effort and the response does not report it. When it does not land, the source URL keeps serving its cached page with a 200 instead of the new 301 until the cache revalidates or expires on its own. For a `prefix` rule only the cached children Base44 already tracks are dropped; the rest fall through the same way.

Both paths start with `/`, are at most 512 characters, and carry no query string or fragment; Base44 strips a trailing slash and decodes percent-escapes before storing them, so `/old/` and `/%6Fld` are the same rule. `target_path` may instead be an absolute `https://` URL to send visitors to another site.

A rule is rejected when its source is a reserved path the redirect layer never sees (`/sitemap.xml`, `/robots.txt`, `/favicon.ico`, `/manifest.json`, `/link_preview.png`, `/llms.txt`, `/.well-known/*`, and the app's auth paths), when source and target are equal, when a `prefix` rule starts at `/`, and when it overlaps another rule or would make a visitor follow two redirects in a row. Overlap is resolved against the whole rule set, so a `prefix` rule at `/docs` blocks a `single` rule at `/docs/intro`, and an internal target that matches any other rule's source is a chain.

An app can hold up to 50 rules; the 51st is rejected with a 400.

<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>

<Note>This endpoint accepts a personal API key. Workspace API keys are not authorized for it and are rejected with a 403.</Note>



## 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 is best effort and the
        response does not report it. When it does not land, the source URL keeps
        serving its cached page with a 200 instead of the new 301 until the
        cache revalidates or expires on its own. For a `prefix` rule only the
        cached children Base44 already tracks are dropped; the rest fall through
        the same way.


        Both paths start with `/`, are at most 512 characters, and carry no
        query string or fragment; Base44 strips a trailing slash and decodes
        percent-escapes before storing them, so `/old/` and `/%6Fld` are the
        same rule. `target_path` may instead be an absolute `https://` URL to
        send visitors to another site.


        A rule is rejected when its source is a reserved path the redirect layer
        never sees (`/sitemap.xml`, `/robots.txt`, `/favicon.ico`,
        `/manifest.json`, `/link_preview.png`, `/llms.txt`, `/.well-known/*`,
        and the app's auth paths), when source and target are equal, when a
        `prefix` rule starts at `/`, and when it overlaps another rule or would
        make a visitor follow two redirects in a row. Overlap is resolved
        against the whole rule set, so a `prefix` rule at `/docs` blocks a
        `single` rule at `/docs/intro`, and an internal target that matches any
        other rule's source is a chain.


        An app can hold up to 50 rules; the 51st is rejected with a 400.


        <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>


        <Note>This endpoint accepts a personal API key. Workspace API keys are
        not authorized for it and are rejected with a 403.</Note>
      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 to manage.
            title: App Id
          description: ID of the app whose URL redirects to manage.
          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: Your workspace 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: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UrlRedirectPayload:
      properties:
        source_path:
          type: string
          maxLength: 512
          minLength: 1
          title: Source Path
          description: >-
            Path visitors request, starting with `/`. 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 them: an internal path starting with `/`, or an
            absolute `https://` URL on another site. Store 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: >-
            `single` redirects that exact path. `prefix` redirects 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: no trailing slash,
            percent-escapes decoded.
          example: /old-pricing
        target_path:
          type: string
          title: Target Path
          description: >-
            Where the visitor is sent. Either an internal path or an absolute
            `https://` URL on another site.
          example: /pricing
        match_type:
          $ref: '#/components/schemas/UrlRedirectMatchType'
          description: >-
            `single` redirects that exact path. `prefix` redirects the path 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.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UrlRedirectMatchType:
      type: string
      enum:
        - single
        - prefix
      title: UrlRedirectMatchType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key
      description: Personal API key.

````