---
title: "Get Masks"
method: POST
path: "/objects/mask_generator"
tags: ["Image Editing"]
---

# Get Masks

`POST /objects/mask_generator`

**Description**

***Note: This API route requires the image to be registered via the `/register` route.***

The *Objects/Mask Generator Route* is used to generate all possible masks for an image, creating a full segmentation of the image.

The response contains a zip file named as the visual_id of the provided image.

There are k mask files in the zip, each named with the visual_id and mask_id.

The zip file contains an additional file whose name ends with "panoptic". It's not an image, it's a panoptic map. It can be transformed into a regular matrix.

Each point in the image (x,y) is mapped to the mask that applies to that point. In the panoptic map, each pixel's grayscale value includes the mask_id. 

You can display those masks to the user, let them pick one or more masks, and use objects/remove route to remove the masked area.

In order to use the objects/remove route on the mask the user selected, you should provide the mask_id, and use the parameter mask_source=generated.

You can see below an example of the content of the zip:


      92bf8ce17584de82_panoptic.png

      
      92bf8ce17584de82_1.png

      
      92bf8ce17584de82_2.png

      
      92bf8ce17584de82_3.png

      
      ...

      
      92bf8ce17584de82_86.png


You can access the SDK that demonstrates how to use this endpoint in a UI in the following <a href="https://github.com/Bria-AI/js-api-sdk/blob/50a062867092788aaa9612f2cc69f7692567115a/mask_hover_ui" target="_blank">link</a>.

## Headers

- `api_token` string, required

## Request body

- object
  - `image_url` string — The URL of the input image. If both image_url and image_file are provided, image_url will be used. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.
  - `file` string — The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

## Response `200`

Successful operation.

- object
  - `objects_masks` string

## Other responses

- `400` — Bad request.
- `404` — Specified Image does not exist.
- `405` — Method not allowed.
- `429` — Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
- `500` — Internal server error.
- `506` — Insufficient data. The given input is not supported by the Bria API.

---

[API](https://skmtc.net/bria-ai/apis/the-bria-api.md) · [All operations](https://skmtc.net/bria-ai/apis/the-bria-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bria-ai/the-bria-api/versions/2768230345a5/schema)
