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

# Remove Background

> Upload an image and get back a cutout of the subject with a transparent background, saved to your Dreep storage as a new asset.

The cutout keeps its alpha channel — it is never flattened onto a colour. To serve it on a background, pass `bg` to the fetch endpoint (`/api/v1/fetch/{id}?bg=ffffff`). That runs as an ordinary transformation, so a single removal can serve any number of background colours without being charged again.

Background removals are billed from a consumable add-on rather than a plan allowance. With no credits remaining the endpoint returns `402`.


## Choosing a background colour

The cutout is stored with its transparency intact and is never flattened onto a
colour. To put it on a background, pass `bg` to the fetch endpoint:

```bash theme={null}
# transparent — the stored cutout
https://api.dreep.cloud/api/v1/fetch/7fa3d9e0.png

# on white
https://api.dreep.cloud/api/v1/fetch/7fa3d9e0.png?bg=ffffff

# on brand navy, resized, as WebP
https://api.dreep.cloud/api/v1/fetch/7fa3d9e0.png?bg=1e3a8a&width=800&format=webp
```

`bg` is hex **without** a leading `#`. Three, six, or eight characters — the
eight-character form carries alpha.

This is why the colour is applied at delivery rather than baked in: one removal
serves any number of backgrounds. Each colour is an ordinary transformation,
cached permanently after its first request, so you are not charged another
removal for it.

## Saving to a folder

Name a destination and the cutout is stored there. Use `folder` (a path,
created on demand) or `folderId` (a UUID):

```bash theme={null}
curl -X POST "https://api.dreep.cloud/api/v1/bg-remove" \
  -H "Authorization: Bearer drp_live_xxxxx" \
  -F "file=@product.jpg" \
  -F "folder=products/cutouts"
```

With no folder given, the cutout is saved to the project's default folder. See
[Folders & Paths](/guides/folders-and-paths).

## Output format

PNG by default. Pass `format=webp` for a smaller file at the same
transparency:

```bash theme={null}
curl -X POST "https://api.dreep.cloud/api/v1/bg-remove" \
  -H "Authorization: Bearer drp_live_xxxxx" \
  -F "file=@product.jpg" \
  -F "format=webp"
```

```json theme={null}
{
  "asset": {
    "id": "7fa3d9e0-fec9-4a76-ac53-4b576500b43a",
    "storageKey": "originals/2b9b4e61/7fa3d9e0.webp",
    "url": "https://api.dreep.cloud/api/v1/fetch/7fa3d9e0.webp",
    "format": "webp",
    "width": 1200,
    "height": 1600,
    "sizeBytes": 184320
  }
}
```

<Note>
  Only `png` and `webp` are accepted. JPEG has no alpha channel, so a cutout
  encoded as JPEG would arrive with a solid background and silently lose the
  transparency you paid for.
</Note>

## Billing

Background removals come from a consumable add-on, not a plan allowance — no
plan includes them by default. Each successful removal spends one credit.

With no credits left the endpoint returns `402` with `code: "LIMIT_EXCEEDED"`
and `featureKey: "bg_removals"`. Credits are only spent once the cutout is
stored, so a failed request costs nothing.


## OpenAPI

````yaml POST /api/v1/bg-remove
openapi: 3.0.0
info:
  title: Dreep API
  description: The universal media processing and storage API.
  version: 1.0.0
servers:
  - url: https://api.dreep.cloud
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/v1/bg-remove:
    post:
      tags:
        - Media
      summary: Remove Background
      description: >
        Upload an image and get back a cutout of the subject with a transparent
        background, saved to your Dreep storage as a new asset.


        The cutout keeps its alpha channel — it is never flattened onto a
        colour. To serve it on a background, pass `bg` to the fetch endpoint
        (`/api/v1/fetch/{id}?bg=ffffff`). That runs as an ordinary
        transformation, so a single removal can serve any number of background
        colours without being charged again.


        Background removals are billed from a consumable add-on rather than a
        plan allowance. With no credits remaining the endpoint returns `402`.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The image to cut out. JPEG, PNG or WebP.
                format:
                  type: string
                  enum:
                    - png
                    - webp
                  default: png
                  description: >
                    Output format. Only alpha-capable formats are accepted — a
                    cutout encoded as JPEG would lose its transparency.
                folder:
                  type: string
                  description: >
                    Slug path of the folder to save the cutout into, relative to
                    the project root. Missing folders are created.
                  example: products/cutouts
                folderId:
                  type: string
                  format: uuid
                  description: >
                    UUID of an existing folder to save the cutout into. Mutually
                    exclusive with `folder`.
                autoCreateFolders:
                  type: string
                  enum:
                    - 'true'
                    - 'false'
                  default: 'true'
                  description: Set to `false` to require that `folder` already exists.
      responses:
        '200':
          description: Background removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  asset:
                    type: object
                    description: The stored cutout.
                    properties:
                      id:
                        type: string
                        format: uuid
                      storageKey:
                        type: string
                      url:
                        type: string
                        description: Fetch URL for the cutout. Accepts transform params.
                      format:
                        type: string
                        enum:
                          - png
                          - webp
                      width:
                        type: integer
                      height:
                        type: integer
                      sizeBytes:
                        type: integer
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >
            No background removal credits remaining. The response body carries
            `code: "LIMIT_EXCEEDED"` and `featureKey: "bg_removals"`.
          content:
            application/json:
              schema:
                $ref: c8af0035-0575-499f-b127-d59e49924d5d
      security:
        - ApiKeyAuth: []
components:
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: boolean
          example: true
        message:
          type: string
          example: Invalid request parameters
        code:
          type: string
          example: invalid_request
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer

````