---
title: "Foreground Mask"
method: POST
path: "/foreground_mask"
tags: ["Masking Endpoints"]
---

# Foreground Mask

`POST /foreground_mask`

Initiates an asynchronous foreground mask generation job for a video.

Response behavior:
- Returns HTTP 202 with `request_id` and `status_url`
- Check job status by polling `status_url` or by calling the [Status Service](https://docs.bria.ai/status) with the `request_id` until a terminal status is returned

Supported input containers:
- .mp4, .mov, .webm, .avi, .gif

Supported input codecs:
- H.264, H.265 (HEVC), VP9, AV1, PhotoJPEG

Input attributes preserved in output:
- Aspect Ratio and resolution
- Frame Rate
- Audio if present

Limits:
- Max input duration: 60 seconds
- Resolutions: Input resolution up to 16000x16000 (16K). Inputs larger than this return 413 Payload Too Large. Output resolution matches the input resolution.

## Headers

- `api_token` string, required

## Request body

- object
  - `video` string, required — Publicly accessible URL of the input video. Input resolution supported up to 16000x16000 (16K)
  - `output_container_and_codec` 'mp4_h264' | 'mp4_h265' | 'webm_vp9' | 'mov_h265' | 'mov_proresks' | 'mkv_h264' | 'mkv_h265' | 'mkv_vp9' | 'gif' — Output container and codec preset
  - `webhook_url` string, uri — Optional URL for receiving the result via webhook when the async job completes. See [Webhooks](https://docs.bria.ai/webhooks).

## Response `202`

Accepted

- AsyncInitialResponse
  - `request_id` string, required
  - `status_url` string, required

## Other responses

- `400` — Bad request
- `403` — Forbidden
- `405` — Method not allowed
- `413` — Payload Too Large
- `415` — Unsupported input container or codec
- `422` — Unprocessable entity
- `429` — Too many requests
- `500` — Internal server error

---

[API](https://skmtc.net/bria-ai/apis/video-api-reference.md) · [All operations](https://skmtc.net/bria-ai/apis/video-api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bria-ai/video-api-reference/revisions/fa6d2efc9689/schema)
