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

> ## Agent Instructions
> This is the Sevalla REST API reference. Base URL: https://api.sevalla.com/v3. Authenticate with an API key in the Authorization header as a Bearer token.
> The OpenAPI spec is at https://api.sevalla.com/v3/openapi.json. Concepts and dashboard guides are at https://docs.sevalla.com (index: https://docs.sevalla.com/llms.txt).
> To act on a Sevalla account from an AI agent, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md) or the Sevalla CLI (https://api-docs.sevalla.com/v3/cli.md).

# Create database backup target

> Attach a backup target to a database. A backup target is an S3-compatible bucket that receives scheduled and manual dump backups. Point it at a Sevalla object storage bucket with `object_storage_id`, or at any external S3-compatible storage with `bucket_name`, `access_key` and `secret_key`. The target configuration is applied to the database asynchronously; scheduled backups start once the apply completes. A database can have up to 5 backup targets. The database and its backups must be in a ready state. Databases that do not support external backups return a 400.



## OpenAPI

````yaml https://api.sevalla.com/v3/openapi.json post /databases/{id}/backup-targets
openapi: 3.1.0
info:
  title: Sevalla API docs
  version: 1.0.0
servers:
  - url: https://api.sevalla.com/v3
security:
  - bearerAuth: []
paths:
  /databases/{id}/backup-targets:
    post:
      tags:
        - Databases
      summary: Create database backup target
      description: >-
        Attach a backup target to a database. A backup target is an
        S3-compatible bucket that receives scheduled and manual dump backups.
        Point it at a Sevalla object storage bucket with `object_storage_id`, or
        at any external S3-compatible storage with `bucket_name`, `access_key`
        and `secret_key`. The target configuration is applied to the database
        asynchronously; scheduled backups start once the apply completes. A
        database can have up to 5 backup targets. The database and its backups
        must be in a ready state. Databases that do not support external backups
        return a 400.
      operationId: createDatabaseBackupTargetV3
      parameters:
        - schema:
            example: fb5e5168-4281-4bec-94c5-0d1584e9e657
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          in: path
          name: id
          required: true
          description: Database identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                display_name:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: Human-readable name for the backup target
                  example: Daily offsite
                schedule:
                  description: >-
                    Cron schedule for automatic dump backups, in standard
                    5-field cron syntax (UTC), for example `15 3 * * *`. The
                    schedule cannot run more often than every 30 minutes. When
                    omitted, backups run daily at a stable, automatically
                    assigned time between 00:00 and 05:59 UTC.
                  example: 15 3 * * *
                  type: string
                  pattern: ^\S+ \S+ \S+ \S+ \S+$
                is_enabled:
                  description: >-
                    Whether automatic scheduled backups are enabled. Defaults to
                    true.
                  example: true
                  type: boolean
                retention_days:
                  description: >-
                    Days automatic backups are kept before being pruned.
                    Defaults to 7.
                  example: 7
                  type: integer
                  minimum: 1
                  maximum: 365
                manual_retention_days:
                  description: >-
                    Days manual backups are kept before being pruned. 0 keeps
                    them forever. Defaults to 14.
                  example: 14
                  type: integer
                  minimum: 0
                  maximum: 365
                prefix:
                  description: >-
                    Object key prefix for the dump files inside the bucket.
                    Defaults to a per-database prefix.
                  example: my-app/db-backups
                  type: string
                  minLength: 1
                  maxLength: 512
                object_storage_id:
                  description: >-
                    Identifier of a Sevalla object storage bucket to upload
                    backups to. Provide either this field or the external S3
                    connection fields, not both.
                  example: fb5e5168-4281-4bec-94c5-0d1584e9e657
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                bucket_name:
                  description: >-
                    Name of the external S3 bucket. Required together with
                    access_key and secret_key for external storage.
                  example: my-backups
                  type: string
                  minLength: 1
                  maxLength: 255
                endpoint:
                  description: S3-compatible endpoint URL of the external storage
                  example: https://account.r2.cloudflarestorage.com
                  type: string
                  format: uri
                region:
                  description: Region of the external storage
                  example: us-east-1
                  type: string
                  minLength: 1
                  maxLength: 64
                access_key:
                  description: >-
                    Access key for the external storage. Stored encrypted and
                    never returned.
                  example: AKIA...
                  type: string
                  minLength: 1
                secret_key:
                  description: >-
                    Secret key for the external storage. Stored encrypted and
                    never returned.
                  example: wJalr...
                  type: string
                  minLength: 1
              required:
                - display_name
      responses:
        '202':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                    description: Backup target identifier
                    example: fb5e5168-4281-4bec-94c5-0d1584e9e657
                  name:
                    type: string
                    description: >-
                      System-generated slug of the backup target, used in dump
                      file names and the backup schedule job name
                    example: daily-offsite
                  display_name:
                    type: string
                    description: Human-readable name of the backup target
                    example: Daily offsite
                  schedule:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: >-
                      Cron schedule of the automatic dump backups, in standard
                      5-field cron syntax (UTC). Null means a daily run at a
                      stable, automatically assigned time between 00:00 and
                      05:59 UTC.
                    example: 15 3 * * *
                  is_enabled:
                    type: boolean
                    description: >-
                      Whether automatic scheduled backups to this target are
                      enabled
                    example: true
                  retention_days:
                    type: number
                    description: >-
                      Days automatic backups are kept in the bucket before being
                      pruned
                    example: 7
                  manual_retention_days:
                    type: number
                    description: >-
                      Days manual backups are kept in the bucket before being
                      pruned. 0 keeps manual backups forever.
                    example: 14
                  prefix:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: >-
                      Object key prefix for the dump files inside the bucket.
                      Null uses the default per-database prefix.
                    example: my-app/db-backups
                  object_storage_id:
                    anyOf:
                      - type: string
                        format: uuid
                        pattern: >-
                          ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                      - type: 'null'
                    description: >-
                      Identifier of the Sevalla object storage bucket this
                      target uploads to. Null when the target uses external
                      S3-compatible storage with customer-provided credentials.
                    example: fb5e5168-4281-4bec-94c5-0d1584e9e657
                  bucket_name:
                    type: string
                    description: Name of the destination bucket
                    example: my-backups
                  endpoint:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: S3-compatible endpoint URL of the destination storage
                    example: https://account.r2.cloudflarestorage.com
                  region:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Region of the destination storage
                    example: auto
                  created_at:
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                    description: >-
                      Timestamp when the backup target was created, in ISO 8601
                      format
                    example: '2025-01-30T00:00:00.000Z'
                  updated_at:
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                    description: >-
                      Timestamp when the backup target was last updated, in ISO
                      8601 format
                    example: '2025-01-30T00:00:00.000Z'
                required:
                  - id
                  - name
                  - display_name
                  - schedule
                  - is_enabled
                  - retention_days
                  - manual_retention_days
                  - prefix
                  - object_storage_id
                  - bucket_name
                  - endpoint
                  - region
                  - created_at
                  - updated_at
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Bad request
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 400
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Unauthorized
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 401
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: >-
                      This API key is missing the <RESOURCE>:<ACTION>
                      permission. Grant it to the key or use a key that has it.
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 403
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Not found
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 404
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '429':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Too many requests
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 429
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Internal Server Error
                  status:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: HTTP status code
                    example: 500
                  data:
                    type: object
                    properties:
                      code:
                        description: Error tracking code for support reference
                        example: err-abc-123
                        type: string
                      message:
                        description: Additional error details or instructions
                        example: >-
                          If you need assistance, please contact support and
                          provide this error code.
                        type: string
                    additionalProperties: false
                required:
                  - message
                  - status
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Pass your API key as a Bearer token in the
        Authorization header.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.