Skip to main content
POST
Resize an image to a new aspect ratio (server-side outpaint)
Resize one source image to a new aspect_ratio. Resize is a server-side outpaint: the backend renders the composition and mask from your source at the target ratio and fills the newly exposed canvas with a style-matched extension. The call returns 202 Accepted with a job id; poll GET /images/resizes/{id} for the result. The image takes exactly one of image_id, url, or base64 + mime_type. Requires the images.transform scope.

Example: one source per mode

The 202 response is the async job handle:
202 Accepted
aspect_ratio is required and one of 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16. resolution (1K default, 2K, 4K) is provider metadata that scales credits — the canvas is always rendered at a 1024px max edge. num_outputs (1–4) defaults to 1 and each output is billed. prompt is optional guidance for the newly generated area (validated when non-empty). placement positions the source on the target canvas: gravity is one of center (default), top, bottom, left, right, top_left, top_right, bottom_left, bottom_right; scale is in (0, 1] (default 1.0 = maximum contain-fit).
Empty-mask no-op. When the requested aspect_ratio + placement leave (almost) no new area to generate — e.g. the source already matches the target ratio at scale = 1 — and no prompt is given, the job skips the model, returns the flattened composition, and refunds the unused outputs. It still completes.

Credits

Each output costs 5 credits at 1K, scaling with resolution (1K ×1, 2K ×2, 4K ×4) and multiplied by num_outputs. See Pricing.

Errors

Authorizations

Authorization
string
header
required

Organization API key as a bearer token: Authorization: Bearer samsa_sk_....

Body

application/json

POST /images/resizes body (SAM-818 / S8.6 — ADR §8, §10).

Resize = server-side outpaint: the backend renders the composition + mask from your source at the target aspect_ratio and fills the newly exposed canvas with a style-matched extension. The source is exactly one of image_id (an image in your organization's context), an https url, or base64+mime_type. aspect_ratio is REQUIRED (validated against the resize engine's supported list). num_outputs defaults to 1; each output is billed at 5 x resolution_multiplier credits (1K:1x, 2K:2x, 4K:4x).

Empty-mask no-op: when the requested aspect_ratio + placement leave (almost) no new area to generate (e.g. the source already matches the target ratio at scale=1) and no prompt is given, the job SKIPS the model, returns the flattened composition, and REFUNDS the unused outputs — it still completes.

image
PublicImageEditSource · object
required

The source image: exactly one of image_id, an https url, or base64+mime_type. The source raster must be at most 33,554,432 pixels (32 MP, width x height) — a larger source returns 422 with param: image before any rendering. The composition canvas is at most 1024px per edge, so higher-resolution sources gain no output detail.

aspect_ratio
string
required

Target aspect ratio (REQUIRED) — one of: 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16.

Example:

"16:9"

resolution
string
default:1K

Provider resolution tier — 1K (default), 2K, or 4K. The canvas is always rendered at a 1024px max edge (per S8.5); the tier is provider metadata that scales credits 1K:1x, 2K:2x, 4K:4x per output.

Example:

"1K"

num_outputs
integer
default:1

Number of images to generate (1-4). Defaults to 1; each output is billed.

Required range: 1 <= x <= 4
Example:

1

prompt
string
default:""

Optional instruction for the newly generated area. When non-empty it runs the app's prompt validation (rejects empty / malformed / policy-violating prompts with a 422).

Example:

"extend the beach and the ocean horizon naturally"

placement
PublicResizePlacement · object | null

Optional placement of the source on the target canvas (gravity + scale). Defaults to centered, maximum contain-fit.

webhook_url
string | null

Optional https webhook notified once on terminal status (signed per the webhook signature scheme; see the webhooks docs).

Example:

"https://example.com/webhooks/samsa"

Response

Successful Response

Shared 202 body for the transform-op submits (SAM-813 / S8 wave).

Every POST /images/<op> returns the async job handle {id, status, estimated_credits}. The initial status is pending (the job is queued), with ONE exception: background-removals and vectorizations answer an owned-image_id cache hit (a ready result already exists for that image) with status: "completed" and estimated_credits: 0 — no new job is queued, the completed webhook event is emitted immediately for a supplied webhook_url, and the result is already available from the op's GET .../{id} endpoint. The other transform ops (img2img, variations, resizes, upscales) always start pending.

id
string<uuid>
required

The job id — poll the op's GET .../{id} endpoint.

status
enum<string>
required

Initial status: pending (job queued — enter the polling flow), or completed with estimated_credits: 0 when background-removals / vectorizations serve an owned-image cache hit (the result is immediately available).

Available options:
pending,
processing,
completed,
failed,
cancelled
Example:

"pending"

estimated_credits
integer
required

Credits this job is expected to cost — 0 on a cache-hit completed response.

Example:

5