API documentation

Background removal over a REST API.

Upload or name an image, get a job id back at once, then read the job or receive a webhook and download the transparent cutout and its 8-bit alpha mask. The reference below is generated from the API's own OpenAPI document.

Base URL
https://api.example.com
Version
v1
Specification
OpenAPI 3.1.1

Getting started

Processing is asynchronous: a submission answers at once with a job id, and the work happens in the background. Coming from remove.bg's API? The migration guide maps its fields and responses.

  1. Create an API key in the dashboard under API keys. It is shown once; keep it in MASKYARD_API_KEY.
  2. Create an upload and send the file straight to storage with its signed URL. For an image that is already online, skip this and submit its public https URL.
  3. Submit the image with an Idempotency-Key. The answer is 202 with the job's id, and one credit is reserved.
  4. Read the job until it succeeds or fails, or register a webhook and wait for job.succeeded.
  5. Download the transparent cutout and its 8-bit alpha mask. The URLs expire after 15 minutes and the files after 30 days: copy them into your own storage.
Shell · cURL and jq
# Needs curl, jq and an API key in MASKYARD_API_KEY; uploads product.jpg.
set -euo pipefail

# 1. Create an upload: a signed URL for one PUT, valid for 15 minutes.
UPLOAD=$(curl -sS --fail-with-body -X POST "https://api.example.com/v1/uploads" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"contentType": "image/jpeg"}')
UPLOAD_ID=$(jq -r .uploadId <<<"$UPLOAD")

# 2. Send the bytes straight to storage, with exactly the headers it names.
curl -sS --fail-with-body -X PUT "$(jq -r .url <<<"$UPLOAD")" \
  -H "Content-Type: image/jpeg" \
  --data-binary @product.jpg

# 3. Submit it: 202 with the job's id. A retry with the same key and body
#    returns the same job; new work needs a new key.
JOB=$(curl -sS --fail-with-body -X POST "https://api.example.com/v1/images" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Idempotency-Key: upload-$UPLOAD_ID" \
  -H "Content-Type: application/json" \
  --data "{\"uploadId\": \"$UPLOAD_ID\"}")
JOB_ID=$(jq -r .id <<<"$JOB")

# 4. Poll until the job ends, or register a webhook instead.
while true; do
  sleep 2
  JOB=$(curl -sS --fail-with-body "https://api.example.com/v1/jobs/$JOB_ID" \
    -H "Authorization: Bearer $MASKYARD_API_KEY")
  case $(jq -r .state <<<"$JOB") in succeeded | failed | cancelled) break ;; esac
done
if [ "$(jq -r .state <<<"$JOB")" != succeeded ]; then
  jq '{state, error}' <<<"$JOB"
  exit 1
fi

# 5. Keep the files: the URLs expire after 15 minutes.
for TYPE in cutout mask; do
  curl -sS --fail-with-body -o "product_$TYPE.png" \
    "$(jq -r --arg type "$TYPE" '.results[] | select(.type == $type) | .url' <<<"$JOB")"
done
TypeScript · Node.js
// Node.js 24 or later: node product.mts; the API key in MASKYARD_API_KEY.
import { readFile, writeFile } from "node:fs/promises";

const API = "https://api.example.com";
const auth = { Authorization: `Bearer ${process.env.MASKYARD_API_KEY}` };

// Errors are application/problem+json with a stable `code`.
async function json(response: Response) {
  const body = await response.json();
  if (!response.ok) {
    throw new Error(`${response.status} ${body.code}: ${body.detail}`);
  }
  return body;
}

// 1. Create an upload: a signed URL for one PUT, valid for 15 minutes.
const upload = await json(
  await fetch(`${API}/v1/uploads`, {
    method: "POST",
    headers: { ...auth, "Content-Type": "application/json" },
    body: JSON.stringify({ contentType: "image/jpeg" }),
  }),
);

// 2. Send the bytes straight to storage, with exactly the headers it names
//    (and not the API key).
const put = await fetch(upload.url, {
  method: upload.method,
  headers: upload.headers,
  body: await readFile("product.jpg"),
});
if (!put.ok) {
  throw new Error(`Upload failed: ${put.status}`);
}

// 3. Submit it: 202 with the job's id. A retry with the same key and body
//    returns the same job; new work needs a new key.
const accepted = await json(
  await fetch(`${API}/v1/images`, {
    method: "POST",
    headers: {
      ...auth,
      "Idempotency-Key": `upload-${upload.uploadId}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ uploadId: upload.uploadId }),
  }),
);

// 4. Poll until the job ends, or register a webhook instead.
let job;
do {
  await new Promise((resolve) => setTimeout(resolve, 2000));
  job = await json(
    await fetch(`${API}/v1/jobs/${accepted.id}`, { headers: auth }),
  );
} while (!["succeeded", "failed", "cancelled"].includes(job.state));
if (job.state !== "succeeded") {
  throw new Error(`The job ${job.state}: ${job.error?.code}`);
}

// 5. Keep the files: the URLs expire after 15 minutes.
for (const result of job.results) {
  if (result.type === "cutout" || result.type === "mask") {
    const file = await fetch(result.url);
    await writeFile(
      `product_${result.type}.png`,
      Buffer.from(await file.arrayBuffer()),
    );
  }
}
C# · .NET
// .NET 10: dotnet run product.cs; the API key in MASKYARD_API_KEY.
// A file-based app compiles for native AOT, which turns reflection-based JSON
// off; this keeps it on. A project needs no such line.
#:property PublishAot=false
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var http = new HttpClient { BaseAddress = new Uri("https://api.example.com/") };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
    "Bearer", Environment.GetEnvironmentVariable("MASKYARD_API_KEY"));

// 1. Create an upload: a signed URL for one PUT, valid for 15 minutes.
var upload = await Read(await http.PostAsJsonAsync("v1/uploads", new { contentType = "image/jpeg" }));

// 2. Send the bytes straight to storage, with exactly the headers it names.
//    Another client: storage must not receive the API key.
using var storage = new HttpClient();
using var put = new HttpRequestMessage(HttpMethod.Put, upload.GetProperty("url").GetString());
put.Content = new ByteArrayContent(await File.ReadAllBytesAsync("product.jpg"));
put.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
(await storage.SendAsync(put)).EnsureSuccessStatusCode();

// 3. Submit it: 202 with the job's id. A retry with the same key and body
//    returns the same job; new work needs a new key.
var uploadId = upload.GetProperty("uploadId").GetString();
using var submit = new HttpRequestMessage(HttpMethod.Post, "v1/images");
submit.Headers.Add("Idempotency-Key", $"upload-{uploadId}");
submit.Content = JsonContent.Create(new { uploadId });
var jobId = (await Read(await http.SendAsync(submit))).GetProperty("id").GetString();

// 4. Poll until the job ends, or register a webhook instead.
JsonElement job;
string? state;
do
{
    await Task.Delay(TimeSpan.FromSeconds(2));
    job = await Read(await http.GetAsync($"v1/jobs/{jobId}"));
    state = job.GetProperty("state").GetString();
}
while (state is not ("succeeded" or "failed" or "cancelled"));
if (state != "succeeded")
{
    throw new InvalidOperationException($"The job {state}: {job.GetProperty("error")}");
}

// 5. Keep the files: the URLs expire after 15 minutes.
foreach (var result in job.GetProperty("results").EnumerateArray())
{
    var type = result.GetProperty("type").GetString();
    if (type is "cutout" or "mask")
    {
        var bytes = await storage.GetByteArrayAsync(result.GetProperty("url").GetString());
        await File.WriteAllBytesAsync($"product_{type}.png", bytes);
    }
}

// Errors are application/problem+json with a stable `code`.
static async Task<JsonElement> Read(HttpResponseMessage response)
{
    var body = await response.Content.ReadFromJsonAsync<JsonElement>();
    if (!response.IsSuccessStatusCode)
    {
        throw new HttpRequestException(
            $"{(int)response.StatusCode} {body.GetProperty("code")}: {body.GetProperty("detail")}");
    }

    return body;
}

Authentication

Send your API key as a bearer token on every request: Authorization: Bearer iak_live_…. A key acts for its account only. We store a hash of it, never the key, so a lost key can't be shown again: create a new one and revoke the old one, which fails from its next request on. Keep keys on your servers, never in a URL or in code that runs in a browser.

A request without a valid key answers 401 unauthenticated. Keys, billing and deleting the account live in the dashboard: a signed-in person manages them there, and no key can.

Requests and responses

  • The base URL is https://api.example.com; every path starts with the version, /v1.
  • Bodies are JSON (Content-Type: application/json) with camelCase fields; values of a fixed set are snake_case, such as awaiting_upload.
  • Times are UTC in ISO 8601 with milliseconds, such as 2026-11-15T09:46:40.000Z. Ids are 24-character strings.
  • A submission answers 202 Accepted with the new resource's id and a Location header to read it at; the work happens in the background.

Idempotency

Submissions take an Idempotency-Key header of 1 to 255 visible ASCII characters without spaces, unique within your account; one derived from your own records works well, such as sku-10442-v1. Send the same key again with the same body and you get the original result, with no second charge: retry a timed-out request with its key and nothing is processed twice. The same key with a different body answers 409 idempotency_key_reused. It applies to:

Pagination

Lists come newest first in pages of up to limit items, with a nextCursor. Pass it as after for the next page; null means it was the last. A batch's items come in submission order, and a webhook endpoint's deliveries take the cursor as cursor.

Files and URLs

Storage is private. Every read of a job, batch, asset or export signs fresh download URLs that work for 15 minutes; store the asset ids, not the URLs, and read GET /v1/assets/{id} for a new URL. After its retention a file is deleted and its read answers 410 file_expired.

Credits

  • One image consumes one credit: reserved when the job is accepted, consumed once its outputs are stored.
  • A job that fails, or is cancelled before it reaches the GPU, releases its credit. Automatic retries never charge twice.
  • Exports, downloads and reads cost nothing; nothing is processed again for them.
  • The credits that expire first are spent first. A submission the account can't cover is refused with 402 insufficient_credits, never charged as overage.
  • GET /v1/usage shows available, reserved and consumed credits and when each grant expires.

Errors

Errors are application/problem+json (RFC 9457) with a stable code: branch on it, not on detail, which is written for people and may change. A published code never changes meaning, but new codes may be added: treat one you don't know by its HTTP status. Each operation in the reference lists the codes it answers.

400 · application/problem+json
{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
  "title": "Bad Request",
  "status": 400,
  "detail": "Processing submissions need an Idempotency-Key header.",
  "code": "idempotency_key_required",
  "traceId": "00-631eb13b1246895c441ffd4489af392d-6c831ebaa63b105c-00"
}
Error codes
CodeStatusMeaning
invalid_request400The request was malformed or missed a required field.
unauthenticated401The request had no valid session token or API key.
insufficient_credits402There weren't enough credits for this work, so nothing was charged. Buy credits or send fewer images.
not_found404It doesn't exist, or it belongs to another account.
unsupported_media_type415The request body's content type isn't accepted.
rate_limited429Too many requests in a short time. Wait a moment and try again.
internal_error500Something went wrong on our side. Try again in a moment.
idempotency_key_required400Processing submissions need an Idempotency-Key header.
idempotency_key_reused409This Idempotency-Key was already used for a different request.
account_restricted403The account is under review after a refund or dispute and can't start new work.
unsafe_url400The URL isn't allowed: it must be a public https address, and so must every redirect.
account_closed403This account was deleted.
job_in_batch409This image belongs to a batch. Delete or retry the batch instead.
file_expired410The file is past its retention period and was deleted.
job_not_cancellable409The job has already finished, so it can't be cancelled.
job_not_succeeded409Only a succeeded job has a result to report.
report_already_open409This job already has an open report.
webhook_endpoint_limit_reached409The account already has the most webhook endpoints allowed.
batch_too_large400The batch has more images than the account's plan allows.
unknown_subject400The subject must be auto, general or jewellery.

Job errors

A job that fails carries its reason in error.code, and a job.failed event in errorCode. Its credit is released.

Job error codes
CodeMeaning
invalid_inputThe file couldn't be read as a complete image.
file_too_largeThe image is larger than 20 MB.
too_many_pixelsThe image has more than 25 megapixels.
unsupported_formatThe file isn't a JPEG, PNG or WebP image.
unsafe_urlThe URL isn't allowed: it must be a public https address, and so must every redirect.
fetch_failedThe image couldn't be downloaded from its URL. Check that it's public and answers within 30 seconds.
processing_failedProcessing failed on every attempt. Submit the image again to retry.
credits_revokedA refund or a payment dispute took back the credits reserved for this image before it was processed, so it didn't run and wasn't charged. Buy credits or contact support, then submit it again.
job_timed_outThe job didn't finish within its time limit and no credit was used. Submit the image again to retry.

Batch item rejections

A batch checks every item on its own and rejects an invalid one by its index, with one of these codes; the other items go ahead.

Batch item codes
CodeMeaning
invalid_itemThe item isn't valid: check its URL, SKU and filename.
unsafe_urlThe URL isn't allowed: it must be a public https address on the standard port.
upload_not_foundThe uploaded file couldn't be found. Upload it again.
file_expiredThe original has expired (kept for 7 days). Upload it again.
insufficient_creditsThe credits ran out before this item was admitted. Nothing was charged.
account_restrictedThe account is under review, so the item wasn't started.

Export errors

Export error codes
CodeMeaning
file_expiredThe outputs of these images have expired. Process them again to export.
output_too_largeThese settings make an image over the limit of 8,192 px a side or 25 megapixels. Export again with a smaller size.
render_failedThe image couldn't be made with these settings, for example a crop when the mask holds no product. Export again with other settings.
processing_failedThe export kept failing for a technical reason. Export again in a few minutes.

Webhooks

Register an endpoint with POST /v1/webhook-endpoints and the API POSTs an event to it when a job or batch ends. The answer carries the endpoint's signing secret, once. Polling keeps working alongside.

Event types
CodeMeaning
job.succeededThe cutout and mask are ready to download.
job.failedThe job ended with an error code; its credit was released.
job.cancelledThe job was cancelled; its credit was released.
batch.completedA batch finished: completed, with failures, or cancelled. Sent again after each retry of its failed items.

Each delivery is a JSON body with the event's id, its type, when it happened (createdAt) and its data: ids and states only, never URLs or image data, so read the job or batch for its results. Three headers come with it: webhook-id, the event id, the same on every attempt; webhook-timestamp, when this attempt was signed; and webhook-signature, the Standard Webhooks signature below.

job.succeeded
{
  "id": "6741f0c2a4b1e3d4f5a6b7c8",
  "type": "job.succeeded",
  "createdAt": "2026-11-13T10:00:00.000Z",
  "data": { "jobId": "6741f0b9a4b1e3d4f5a6b7c1", "state": "succeeded" }
}
Job event data
FieldMeaning
jobIdThe job.
batchIdThe job's batch, for a batch item; absent for a single job.
stateThe job's terminal state. One of succeeded, failed, cancelled.
errorCodeWhy it failed, for job.failed; absent otherwise. One of invalid_input, file_too_large, too_many_pixels, unsupported_format, unsafe_url, fetch_failed, processing_failed, credits_revoked, job_timed_out.
Batch event data
FieldMeaning
batchIdThe batch.
completion1 for the first ending, 2 after the first retry has finished, and so on: ignore a completion lower than one you have seen.
statusThe batch's status when it ended. One of completed, completed_with_failures, cancelled.
countsIts items by state when it ended, as GET /v1/batches/{id} counts them.

Delivery and retries

Answer with a 2xx within 10 seconds. No answer, a redirect, 429 or a 5xx is retried after 5 s, 30 s, 2 min, 10 min, 1 h, 3 h, 6 h, 12 h (9 attempts in all); another 4xx is not. A Retry-After header can lengthen a wait. Delivery is at least once, so deduplicate on webhook-id. A batch sends batch.completed again after each retry of its failed items has finished, with a higher completion: ignore one lower than a completion you have seen.

Verifying signatures

Check every delivery before trusting it: compute the HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body} keyed with the base64 bytes after whsec_ in the secret, compare it in constant time with the v1, entries of webhook-signature, and refuse old timestamps. Rotating the secret (POST /v1/webhook-endpoints/{id}/rotate-secret) keeps the old one signing for 24 hours, so deliveries carry both signatures meanwhile.

TypeScript
import { createHmac, timingSafeEqual } from "node:crypto";

// Verifies a delivery. Pass the raw body as received, before any JSON
// parsing, and the endpoint's whsec_… signing secret.
export function verifyWebhook(
  secret: string,
  headers: { id: string; timestamp: string; signature: string },
  body: string | Buffer,
): boolean {
  const timestamp = Number(headers.timestamp);
  if (!Number.isInteger(timestamp)) {
    return false;
  }
  // More than five minutes off: a replayed request or a wrong clock.
  if (Math.abs(Date.now() / 1000 - timestamp) > 300) {
    return false;
  }
  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const mac = createHmac("sha256", key)
    .update(`${headers.id}.${headers.timestamp}.`)
    .update(body)
    .digest("base64");
  const expected = Buffer.from(`v1,${mac}`);
  // During a secret rotation two signatures arrive: either may match.
  return headers.signature.split(" ").some((entry) => {
    const candidate = Buffer.from(entry);
    return (
      candidate.length === expected.length &&
      timingSafeEqual(candidate, expected)
    );
  });
}

C#
using System.Security.Cryptography;
using System.Text;

public static class WebhookSignature
{
    // Verifies a delivery. Pass the raw body as received, before any JSON
    // parsing, and the endpoint's whsec_… signing secret.
    public static bool Verify(
        string secret, string id, string timestamp, string signature, byte[] body)
    {
        if (!long.TryParse(timestamp, out var seconds))
        {
            return false;
        }

        // More than five minutes off: a replayed request or a wrong clock.
        if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - seconds) > 300)
        {
            return false;
        }

        var key = Convert.FromBase64String(
            secret.StartsWith("whsec_") ? secret["whsec_".Length..] : secret);
        byte[] signed = [.. Encoding.UTF8.GetBytes($"{id}.{timestamp}."), .. body];
        var expected = Encoding.ASCII.GetBytes(
            "v1," + Convert.ToBase64String(HMACSHA256.HashData(key, signed)));
        // During a secret rotation two signatures arrive: either may match.
        return signature
            .Split(' ', StringSplitOptions.RemoveEmptyEntries)
            .Any(entry => CryptographicOperations.FixedTimeEquals(
                expected, Encoding.ASCII.GetBytes(entry)));
    }
}

Limits and retention

These are the launch values. GET /v1/limits answers your account's own, read from what enforces them, and GET /v1/queue shows what is waiting.

Per image
FormatsJPEG, PNG and WebP, judged by the decoded file
File size20 MB per image
Pixels25 megapixels per image
Image URLsPublic https on port 443, at most 2,048 characters; downloaded within 30 seconds, following at most 3 redirects
OutputsA transparent PNG cutout and an 8-bit alpha-mask PNG at the source's dimensions, upright and in sRGB; inference may run at a smaller internal resolution
Per account
Batch size25 images on the trial, 1,000 on a paid plan
Jobs on the GPU at once25 per account, on the trial too; the rest wait in the queue
Requests600 a minute per API key and 1,200 a minute per account; 120 a minute per address without a valid key
Exports30 created an hour; 2 running at once
Export filesZIP parts of about 1 GiB; a variant at most 8,192 pixels a side and 25 megapixels
Webhook endpoints10 per account
Retention
Originals7 days
Cutouts, masks and previews30 days after the job completed
Export files24 hours after the export completed
Uploads no job used24 hours after the upload URL expired
Jobs, batches and credit historyListed for 90 days
Unfinished jobsFail with job_timed_out 24 hours after submission; the credit is released
Signed URLs15 minutes, signed afresh on every read

Reference

Every operation, from the API's OpenAPI document. The C# examples use the http client from getting started, which sends the key; responses are read as JsonElement.

Uploads

Allocate an input and send its bytes straight to storage with the signed URL.

Create an upload

POST/v1/uploads

Allocates an input and signs one PUT to private storage, so the bytes go straight there and never through the API. Size, type and pixel count are checked when a job validates the upload, not here.

Request body
FieldDescription
contentTypestring requiredThe file's type; the upload URL is signed for it. One of image/jpeg, image/png, image/webp.
201 Created: UploadResponse
Response 201 fields
FieldDescription
uploadIdstring requiredThe upload's id, for the submission.
urlstring requiredThe signed storage URL; it takes one PUT of this file.
methodstring requiredAlways PUT.
headersobject requiredHeaders the PUT must carry exactly (Content-Type).
urlExpiresAtdate-time requiredWhen the URL stops working (15 minutes).
expiresAtdate-time requiredWhen the stored original is deleted (7 days); an upload no job took is deleted 24 hours after its URL expired.
cURL
curl -X POST "https://api.example.com/v1/uploads" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "contentType": "image/jpeg"
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/uploads`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    contentType: "image/jpeg",
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, "v1/uploads");
request.Content = JsonContent.Create(new
{
    contentType = "image/jpeg",
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Jobs

One image, processed asynchronously: submit, read, list, cancel, delete, and the account's queue.

Submit an image

POST/v1/images

Creates a job for one image, from an upload (POST /v1/uploads) or a public https URL, and reserves one credit for it. Answers 202 with the job's id at once; processing is asynchronous: read the job, or receive a webhook when it ends. A replay with the same Idempotency-Key and body returns the same job.

Parameters
FieldDescription
Idempotency-Key (header)string requiredYour key for this submission, scoped to the account: a replay with the same key and body returns the original result without charging again. 1 to 255 visible ASCII characters, no spaces.
Request body
FieldDescription
uploadIdstringThe uploadId from POST /v1/uploads; PUT the bytes before the upload URL expires.
urlstringA public https image URL on port 443, at most 2,048 characters; private and internal addresses are refused.
subjectstringWhat the image shows, for the model that processes it: auto (the default) checks each image for jewellery and uses the jewellery model for rings, earrings, necklaces, bracelets and watches; general or jewellery is your statement and skips the check. Products other than jewellery set to jewellery may come out worse. Omitted is auto, and the same request. One of auto, general, jewellery.
202 Accepted: AcceptedJobResponse
Response 202 fields
FieldDescription
idstring requiredThe job's id.
statestring requiredawaiting_upload until an upload's bytes are stored, else validating. One of awaiting_upload, validating, queued, running, succeeded, failed, cancelled.
cURL
curl -X POST "https://api.example.com/v1/images" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Idempotency-Key: sku-10442-v1" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "url": "https://cdn.example.com/catalogue/sku-10442.jpg"
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/images`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Idempotency-Key": "sku-10442-v1",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://cdn.example.com/catalogue/sku-10442.jpg",
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, "v1/images");
request.Headers.Add("Idempotency-Key", "sku-10442-v1");
request.Content = JsonContent.Create(new
{
    url = "https://cdn.example.com/catalogue/sku-10442.jpg",
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

List jobs

GET/v1/jobs

The account's jobs, newest first, without download URLs (read a job for those). A batch's retried items appear once, as their newest job.

Parameters
FieldDescription
after (query)stringThe nextCursor of the previous page.
limit (query)integerJobs per page. Default 25.
state (query)stringOnly jobs in this state. One of awaiting_upload, validating, queued, running, succeeded, failed, cancelled.
batchId (query)stringOnly the items of this batch.
200 OK: JobListResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe jobs on this page.
items[].idstring requiredThe job's id.
items[].statestring requiredThe job's state. One of awaiting_upload, validating, queued, running, succeeded, failed, cancelled.
items[].errorCodestring or null requiredWhy it failed; null unless failed. One of invalid_input, file_too_large, too_many_pixels, unsupported_format, unsafe_url, fetch_failed, processing_failed, credits_revoked, job_timed_out.
items[].createdAtdate-time requiredWhen the job was submitted.
items[].completedAtdate-time or null requiredWhen it reached a terminal state.
items[].batchIdstring or null requiredThe batch's id, for a batch item.
items[].itemIndexinteger or null requiredThe item's index, for a batch item.
items[].skustring or null requiredThe item's SKU, for a batch item.
items[].filenamestring or null requiredThe item's filename, for a batch item.
items[].sourceobject requiredWhere the image came from.
items[].source.kindstring requiredupload or url. One of upload, url.
items[].source.urlstring or null requiredA url input's host and path, without query string.
items[].batchobject or null requiredThe batch item this job is; null for a single job.
items[].batch.idstring requiredThe batch's id.
items[].batch.indexinteger requiredThe item's position in the submission, from 0.
items[].batch.skustring or null requiredThe SKU sent with the item.
items[].batch.filenamestring or null requiredThe filename sent with the item.
nextCursorstring or null requiredPass as after for the next page; null on the last.
cURL
curl "https://api.example.com/v1/jobs?state=failed&limit=50" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/jobs?state=failed&limit=50`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/jobs?state=failed&limit=50");

Read a job

GET/v1/jobs/{id}

The job's state, error, subject, model version and results. Every read signs fresh download URLs for the input and the outputs, valid for 15 minutes; store the asset ids, never the URLs.

Parameters
FieldDescription
id (path)string required
200 OK: JobResponse
Response 200 fields
FieldDescription
idstring requiredThe job's id.
statestring requiredawaiting_upload, validating, queued, running, then succeeded, failed or cancelled. One of awaiting_upload, validating, queued, running, succeeded, failed, cancelled.
inputobject requiredWhat the job processes.
input.typestring requiredupload or url. One of upload, url.
input.uploadIdstring or null requiredThe upload's id, for an upload.
input.urlstring or null requiredThe image URL, for a url input.
input.downloadUrlstring or null requiredThe original, signed for 15 minutes; null until it is stored and validated, and after expiresAt.
input.expiresAtdate-time requiredWhen the original is deleted (7 days after it was stored).
errorobject or null requiredWhy it failed; null unless failed.
error.codestring requiredA stable code; see the job error codes. One of invalid_input, file_too_large, too_many_pixels, unsupported_format, unsafe_url, fetch_failed, processing_failed, credits_revoked, job_timed_out.
error.messagestring requiredFor a person to read; may change.
attemptsinteger requiredGPU attempts so far; technical failures are retried automatically, and never charged twice.
subjectobject requiredThe subject requested and the one used.
subject.requestedstring requiredauto, general or jewellery, as submitted (auto when omitted). One of auto, general, jewellery.
subject.usedstring or null requiredgeneral or jewellery; null until the input is validated. One of auto, general, jewellery.
subject.detectedboolean or null requiredWhether the automatic check chose the subject used: true for an auto request it answered; false when you set the subject or the check gave no answer (then general is used); null until validated.
modelVersionstring or null requiredThe model that produced the result; null before processing.
sourceHashstring or null requiredThe source bytes' hash as sha256:<hex>; null until validated.
sourceobject or null requiredThe validated source image; null until validated.
source.formatstring requiredjpeg, png or webp.
source.widthinteger requiredPixels, upright (the EXIF orientation applied).
source.heightinteger requiredPixels, upright.
source.bytesinteger requiredThe file's size.
cancelRequestedAtdate-time or null requiredWhen a cancellation was asked for.
createdAtdate-time requiredWhen the job was submitted.
updatedAtdate-time requiredWhen the job last changed.
completedAtdate-time or null requiredWhen it reached a terminal state.
resultsarray of object requiredThe outputs of a succeeded job: cutout, mask and, when rendered, preview.
results[].assetIdstring requiredThe output's id: store this, and read GET /v1/assets/{id} for a fresh URL.
results[].typestring requiredcutout (transparent PNG), mask (8-bit alpha PNG) or preview (WebP within 320×320). One of cutout, mask, preview.
results[].widthinteger requiredPixels.
results[].heightinteger requiredPixels.
results[].expiresAtdate-time requiredWhen the file is deleted (30 days after the job completed).
results[].urlstring or null requiredThe file, signed for 15 minutes; null once expired.
batchobject or null requiredThe batch item this job is; null for a single job.
batch.idstring requiredThe batch's id.
batch.indexinteger requiredThe item's position in the submission, from 0.
batch.skustring or null requiredThe SKU sent with the item.
batch.filenamestring or null requiredThe filename sent with the item.
cURL
curl "https://api.example.com/v1/jobs/$JOB_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/jobs/${jobId}`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>($"v1/jobs/{jobId}");

Delete a job

DELETE/v1/jobs/{id}

Deletes the job's input, outputs and the export files that contain them, and stops it if it hasn't finished. The job reads as not found from this request on. 202 while the files are being deleted, 200 once they are; asking again is safe. A batch item is deleted with its batch (job_in_batch).

Parameters
FieldDescription
id (path)string required
200 or 202 OK or Accepted: DeletionResponse
Response 200 or 202 fields
FieldDescription
idstring requiredThe job's, batch's or account's id.
statestring requireddeleting or deleted.
requestedAtdate-time requiredWhen the deletion was asked for.
completedAtdate-time or null requiredWhen the last file was deleted.
cURL
curl -X DELETE "https://api.example.com/v1/jobs/$JOB_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/jobs/${jobId}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var response = await http.DeleteAsync($"v1/jobs/{jobId}");
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Cancel a job

POST/v1/jobs/{id}/cancel

A job not yet on the GPU is cancelled at once and its credit released (200). A running job is asked to stop (202, executionStarted true): a result stored before the cancellation takes effect is still charged; otherwise the credit is released.

Parameters
FieldDescription
id (path)string required
200 or 202 OK or Accepted: CancelJobResponse
Response 200 or 202 fields
FieldDescription
idstring requiredThe job's id.
statestring requiredcancelled when it stopped before the GPU; running while a running job is asked to stop. One of awaiting_upload, validating, queued, running, succeeded, failed, cancelled.
executionStartedboolean requiredThe job had reached the GPU: a result stored before the cancellation takes effect is charged.
cURL
curl -X POST "https://api.example.com/v1/jobs/$JOB_ID/cancel" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/jobs/${jobId}/cancel`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var response = await http.SendAsync(new HttpRequestMessage(HttpMethod.Post, $"v1/jobs/{jobId}/cancel"));
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Read the queue

GET/v1/queue

The account's unfinished jobs by state, its in-flight limit and its oldest queued job.

200 OK: QueueResponse
Response 200 fields
FieldDescription
awaitingUploadinteger requiredJobs waiting for their upload's bytes.
validatinginteger requiredJobs being fetched or checked.
queuedinteger requiredJobs waiting for a GPU slot.
runninginteger requiredJobs on the GPU; at most inFlightLimit at once.
inFlightLimitinteger requiredHow many of the account's jobs run at once at its tier; more stay queued.
tierstring requiredtrial or paid. One of trial, paid.
oldestQueuedobject or null requiredThe job queued longest; null when none is queued.
oldestQueued.jobIdstring requiredThe job's id.
oldestQueued.createdAtdate-time requiredWhen it was submitted.
oldestQueued.ageSecondsinteger requiredWhole seconds since it was submitted, as of this response.
cURL
curl "https://api.example.com/v1/queue" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/queue`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/queue");

Batches

Many images as one batch: a dry run, submission, items page by page, cancel, retry of technical failures, deletion.

List batches

GET/v1/batches

The account's batches, newest first, with their counts.

Parameters
FieldDescription
after (query)stringThe nextCursor of the previous page.
limit (query)integerBatches per page. Default 20.
200 OK: BatchListResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe batches on this page.
items[].idstring requiredThe batch's id.
items[].namestring or null requiredThe batch's name.
items[].statusstring requiredThe batch's status. One of validating, processing, completed, completed_with_failures, cancelled.
items[].itemCountinteger requiredItems submitted.
items[].countsobject requiredItems by state.
items[].counts.totalinteger requiredEvery item.
items[].counts.pendinginteger requiredItems not yet admitted.
items[].counts.awaitingUploadinteger requiredWaiting for an upload's bytes.
items[].counts.validatinginteger requiredBeing fetched or checked.
items[].counts.queuedinteger requiredWaiting for a GPU slot.
items[].counts.runninginteger requiredOn the GPU.
items[].counts.succeededinteger requiredWith outputs.
items[].counts.failedinteger requiredFailed.
items[].counts.cancelledinteger requiredCancelled.
items[].counts.rejectedinteger requiredRejected at submission.
items[].createdAtdate-time requiredWhen the batch was submitted.
items[].admittedAtdate-time or null requiredWhen admission finished.
items[].cancelRequestedAtdate-time or null requiredWhen a cancellation was asked for.
nextCursorstring or null requiredPass as after for the next page; null on the last.
cURL
curl "https://api.example.com/v1/batches" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/batches`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/batches");

Submit a batch

POST/v1/batches

Creates one job per valid item and reserves one credit each. Every item is checked on its own; an invalid one is rejected by index with a code and the rest go ahead (202). With validateOnly=true nothing is written: the answer (200) lists the rejections and the credits the valid items need against those available. Short of credits for the valid items, nothing is created (402).

Parameters
FieldDescription
Idempotency-Key (header)stringYour key for this submission, scoped to the account: a replay with the same key and body returns the original result without charging again. 1 to 255 visible ASCII characters, no spaces. Required unless validateOnly=true, which ignores it.
validateOnly (query)booleanCheck the items and the credits without creating anything.
Request body
FieldDescription
namestringA name for the batch, 1 to 200 characters.
itemsarray of object requiredThe images, at least one; at most the account's batch limit (GET /v1/limits).
items[].uploadIdstringThe uploadId from POST /v1/uploads.
items[].urlstringA public https image URL on port 443, at most 2,048 characters.
items[].skustringYour SKU, 1 to 255 characters; kept for the manifest and download names.
items[].filenamestringThe original filename, 1 to 255 characters; kept for the manifest and download names.
subjectstringWhat the image shows, for the model that processes it: auto (the default) checks each image for jewellery and uses the jewellery model for rings, earrings, necklaces, bracelets and watches; general or jewellery is your statement and skips the check. Products other than jewellery set to jewellery may come out worse. Omitted is auto, and the same request. It applies to every item. One of auto, general, jewellery.
200 OK: BatchValidationResponse
Response 200 fields
FieldDescription
itemsobject requiredThe valid and the rejected items.
items.validinteger requiredItems that would become jobs.
items.rejectedarray of object requiredItems that wouldn't, by index, with the reason.
items.rejected[].indexinteger requiredIts position in the submission, from 0.
items.rejected[].codestring requiredWhy; see the batch item codes. One of invalid_item, unsafe_url, upload_not_found, file_expired, insufficient_credits, account_restricted.
items.rejected[].messagestring requiredFor a person to read; may change.
items.rejected[].skustring or null requiredThe SKU sent with it.
items.rejected[].filenamestring or null requiredThe filename sent with it.
creditsobject requiredThe credits the valid items need.
credits.requiredinteger requiredOne per valid item.
credits.availableinteger requiredThe account's available credits.
credits.shortfallinteger requiredCredits missing; 0 when there are enough.
limitinteger requiredThe most items a batch may hold on this account.
202 Accepted: AcceptedBatchResponse
Response 202 fields
FieldDescription
idstring requiredThe batch's id.
itemsobject requiredWhat it admitted.
items.admittedinteger requiredItems that became jobs, one credit reserved each.
items.rejectedarray of object requiredItems that didn't, by index, with the reason.
items.rejected[].indexinteger requiredIts position in the submission, from 0.
items.rejected[].codestring requiredWhy; see the batch item codes. One of invalid_item, unsafe_url, upload_not_found, file_expired, insufficient_credits, account_restricted.
items.rejected[].messagestring requiredFor a person to read; may change.
items.rejected[].skustring or null requiredThe SKU sent with it.
items.rejected[].filenamestring or null requiredThe filename sent with it.
cURL
curl -X POST "https://api.example.com/v1/batches" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Idempotency-Key: november-import-1" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "name": "November import",
  "items": [
    {
      "url": "https://cdn.example.com/catalogue/sku-10442.jpg",
      "sku": "SKU-10442",
      "filename": "sku-10442.jpg"
    },
    {
      "url": "https://cdn.example.com/catalogue/sku-10443.png",
      "sku": "SKU-10443",
      "filename": "sku-10443.png"
    }
  ]
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/batches`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Idempotency-Key": "november-import-1",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "November import",
    items: [
      {
        url: "https://cdn.example.com/catalogue/sku-10442.jpg",
        sku: "SKU-10442",
        filename: "sku-10442.jpg",
      },
      {
        url: "https://cdn.example.com/catalogue/sku-10443.png",
        sku: "SKU-10443",
        filename: "sku-10443.png",
      },
    ],
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, "v1/batches");
request.Headers.Add("Idempotency-Key", "november-import-1");
request.Content = JsonContent.Create(new
{
    name = "November import",
    items = new object[]
    {
        new
        {
            url = "https://cdn.example.com/catalogue/sku-10442.jpg",
            sku = "SKU-10442",
            filename = "sku-10442.jpg",
        },
        new
        {
            url = "https://cdn.example.com/catalogue/sku-10443.png",
            sku = "SKU-10443",
            filename = "sku-10443.png",
        },
    },
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Read a batch

GET/v1/batches/{id}

The batch's status and counts, derived from its items, and a page of items in submission order (rejected ones in place), each with its results and download URLs signed for this read.

Parameters
FieldDescription
id (path)string required
after (query)stringThe nextCursor of the previous page.
limit (query)integerItems per page. Default 50.
200 OK: BatchResponse
Response 200 fields
FieldDescription
idstring requiredThe batch's id.
namestring or null requiredThe batch's name.
subjectstring requiredThe subject requested for every item: auto, general or jewellery (auto when omitted). One of auto, general, jewellery.
statusstring requiredvalidating, processing, then completed, completed_with_failures or cancelled. One of validating, processing, completed, completed_with_failures, cancelled.
itemCountinteger requiredItems submitted, rejected ones included.
countsobject requiredItems by state.
counts.totalinteger requiredEvery item.
counts.pendinginteger requiredItems not yet admitted.
counts.awaitingUploadinteger requiredWaiting for an upload's bytes.
counts.validatinginteger requiredBeing fetched or checked.
counts.queuedinteger requiredWaiting for a GPU slot.
counts.runninginteger requiredOn the GPU.
counts.succeededinteger requiredWith outputs.
counts.failedinteger requiredFailed.
counts.cancelledinteger requiredCancelled.
counts.rejectedinteger requiredRejected at submission.
createdAtdate-time requiredWhen the batch was submitted.
admittedAtdate-time or null requiredWhen every valid item had become a job; null while admission runs.
cancelRequestedAtdate-time or null requiredWhen a cancellation was asked for.
itemsarray of object requiredThis page's items, in submission order.
items[].indexinteger requiredIts position in the submission, from 0.
items[].skustring or null requiredThe SKU sent with it.
items[].filenamestring or null requiredThe filename sent with it.
items[].statestring requiredThe job's state, or rejected. One of awaiting_upload, validating, queued, running, succeeded, failed, cancelled, rejected.
items[].jobIdstring or null requiredThe item's current job (after a retry, the new one); null when rejected.
items[].errorobject or null requiredWhy it failed or was rejected.
items[].error.codestring requiredA stable code; see the job error codes. One of invalid_input, file_too_large, too_many_pixels, unsupported_format, unsafe_url, fetch_failed, processing_failed, credits_revoked, job_timed_out.
items[].error.messagestring requiredFor a person to read; may change.
items[].resultsarray of object requiredA succeeded item's outputs.
items[].results[].assetIdstring requiredThe output's id: store this, and read GET /v1/assets/{id} for a fresh URL.
items[].results[].typestring requiredcutout (transparent PNG), mask (8-bit alpha PNG) or preview (WebP within 320×320). One of cutout, mask, preview.
items[].results[].widthinteger requiredPixels.
items[].results[].heightinteger requiredPixels.
items[].results[].expiresAtdate-time requiredWhen the file is deleted (30 days after the job completed).
items[].results[].urlstring or null requiredThe file, signed for 15 minutes; null once expired.
nextCursorstring or null requiredPass as after for the next page; null on the last.
cURL
curl "https://api.example.com/v1/batches/$BATCH_ID?limit=100" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/batches/${batchId}?limit=100`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>($"v1/batches/{batchId}?limit=100");

Delete a batch

DELETE/v1/batches/{id}

Deletes the batch's items, their inputs and outputs and the export files that contain them, and stops what hasn't finished. The batch reads as not found from this request on. 202 while deleting, 200 once done; asking again is safe.

Parameters
FieldDescription
id (path)string required
200 or 202 OK or Accepted: DeletionResponse
Response 200 or 202 fields
FieldDescription
idstring requiredThe job's, batch's or account's id.
statestring requireddeleting or deleted.
requestedAtdate-time requiredWhen the deletion was asked for.
completedAtdate-time or null requiredWhen the last file was deleted.
cURL
curl -X DELETE "https://api.example.com/v1/batches/$BATCH_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/batches/${batchId}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var response = await http.DeleteAsync($"v1/batches/{batchId}");
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Cancel a batch

POST/v1/batches/{id}/cancel

Stops admission and cancels every unfinished item: items not yet on the GPU stop and release their credits; running ones are asked to stop (202), and a result stored before that takes effect is charged.

Parameters
FieldDescription
id (path)string required
200 or 202 OK or Accepted: CancelBatchResponse
Response 200 or 202 fields
FieldDescription
idstring requiredThe batch's id.
cancelledinteger requiredItems stopped before the GPU; their credits were released.
runninginteger requiredItems on the GPU, asked to stop; a result stored before that takes effect is charged.
cURL
curl -X POST "https://api.example.com/v1/batches/$BATCH_ID/cancel" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/batches/${batchId}/cancel`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var response = await http.SendAsync(new HttpRequestMessage(HttpMethod.Post, $"v1/batches/{batchId}/cancel"));
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Retry failed items

POST/v1/batches/{id}/retry

Retries the items that failed for a technical reason (processing_failed, fetch_failed, job_timed_out) as new jobs, one credit each; input refusals would fail again and are left alone. 202 when items were retried, 200 when none could be. Short of credits for all of them, nothing is retried (402). The batch sends batch.completed again once the retried items have finished.

Parameters
FieldDescription
id (path)string required
Idempotency-Key (header)string requiredYour key for this submission, scoped to the account: a replay with the same key and body returns the original result without charging again. 1 to 255 visible ASCII characters, no spaces.
200 or 202 OK or Accepted: RetryBatchResponse
Response 200 or 202 fields
FieldDescription
idstring requiredThe batch's id.
retriedinteger requiredItems retried as new jobs, one credit reserved each.
rejectedarray of object requiredFailed items that couldn't be retried (an expired input, say), by index.
rejected[].indexinteger requiredIts position in the submission, from 0.
rejected[].codestring requiredWhy; see the batch item codes. One of invalid_item, unsafe_url, upload_not_found, file_expired, insufficient_credits, account_restricted.
rejected[].messagestring requiredFor a person to read; may change.
rejected[].skustring or null requiredThe SKU sent with it.
rejected[].filenamestring or null requiredThe filename sent with it.
cURL
curl -X POST "https://api.example.com/v1/batches/$BATCH_ID/retry" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Idempotency-Key: november-import-1-retry-1"
TypeScript
const response = await fetch(`https://api.example.com/v1/batches/${batchId}/retry`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Idempotency-Key": "november-import-1-retry-1",
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, $"v1/batches/{batchId}/retry");
request.Headers.Add("Idempotency-Key", "november-import-1-retry-1");
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Exports

Formatted variants and batch ZIP files, made from stored outputs on the CPU: no credits, no new inference.

List exports

GET/v1/exports

The account's exports, newest first, without download URLs (read an export for those).

Parameters
FieldDescription
after (query)stringThe nextCursor of the previous page.
limit (query)integerExports per page. Default 20.
200 OK: ExportListResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe exports on this page.
items[].idstring requiredThe export's id.
items[].kindstring requiredvariant or batch_zip. One of variant, batch_zip.
items[].statestring requiredqueued, running, succeeded or failed. One of queued, running, succeeded, failed.
items[].jobIdstring or null requiredA variant's job.
items[].batchIdstring or null requiredA ZIP export's batch.
items[].errorCodestring or null requiredWhy it failed; see the export error codes. One of file_expired, output_too_large, render_failed, processing_failed.
items[].partCountinteger requiredFiles made: ZIP parts, or the one variant.
items[].fileCountinteger requiredThe parts and the manifest; 0 until it succeeds.
items[].totalBytesinteger or null requiredTheir sizes summed; null until it succeeds.
items[].createdAtdate-time requiredWhen the export was requested.
items[].completedAtdate-time or null requiredWhen it succeeded or failed.
items[].expiresAtdate-time or null requiredWhen its files are deleted (24 hours after completion).
nextCursorstring or null requiredPass as after for the next page; null on the last.
cURL
curl "https://api.example.com/v1/exports" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/exports`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/exports");

Create an export

POST/v1/exports

Makes files from stored outputs on the CPU, with no new inference and no credits: a formatted variant of one succeeded job (jobId with spec), or a batch's files as ZIP parts of about 1 GiB with a CSV manifest (batchId). Asynchronous: read the export until it succeeds. An identical variant made recently is reused. Export creation has its own hourly limit per account.

Parameters
FieldDescription
Idempotency-Key (header)string requiredYour key for this submission, scoped to the account: a replay with the same key and body returns the original result without charging again. 1 to 255 visible ASCII characters, no spaces.
Request body
FieldDescription
jobIdstringA succeeded job: one formatted variant of its cutout.
batchIdstringA batch: its succeeded items' files in ZIP parts.
specobjectHow to format the variant; required with jobId, and with variant in include.
spec.cropobject
spec.crop.thresholdintegerThe alpha (0 to 254) a pixel must exceed to count as the product. Default 8.
spec.crop.marginobjectA distance: whole source pixels, or a percentage (0 to 100) of the content's longer side.
spec.paddingobjectA distance: whole source pixels, or a percentage (0 to 100) of the content's longer side.
spec.padding.valuenumber requiredThe distance: whole pixels, or 0 to 100 percent.
spec.padding.unitstring required One of pixels, percent.
spec.resizeobject
spec.resize.widthintegerThe output's width in pixels.
spec.resize.heightintegerThe output's height in pixels.
spec.resize.modestring One of fit, letterbox. Default "fit".
spec.placementobject
spec.placement.canvasWidthinteger requiredThe canvas's width in pixels.
spec.placement.canvasHeightinteger requiredThe canvas's height in pixels.
spec.placement.scalePercentnumber requiredThe share of the canvas (1 to 100) the product may fill.
spec.placement.anchorstring One of top_left, top, top_right, left, center, right, bottom_left, bottom, bottom_right. Default "center".
spec.backgroundstringAn opaque sRGB colour as #RRGGBB.
spec.silhouettestringAn opaque sRGB colour as #RRGGBB.
spec.formatstring One of png, webp. Default "png".
spec.qualityintegerWebP's quality, 1 to 100. Default 90.
spec.losslessbooleanLossless WebP. Default false.
spec.maxUpscalenumberHow far a resize or placement may enlarge the product: 1 never enlarges. Default 1.
includearray of stringA batch's files per item: cutout, mask, variant (needs spec). Default: cutout and mask. One of cutout, mask, variant.
manifestbooleanA batch's CSV manifest, a row per item, failures included. Default: true.
202 Accepted: AcceptedExportResponse
Response 202 fields
FieldDescription
idstring requiredThe export's id.
statestring requiredqueued, or succeeded at once when an identical variant was reused. One of queued, running, succeeded, failed.
cURL
curl -X POST "https://api.example.com/v1/exports" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Idempotency-Key: sku-10442-card-v1" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "jobId": "$JOB_ID",
  "spec": {
    "crop": {
      "margin": {
        "value": 4,
        "unit": "percent"
      }
    },
    "placement": {
      "canvasWidth": 1200,
      "canvasHeight": 1200,
      "scalePercent": 90
    },
    "background": "#FFFFFF",
    "format": "webp",
    "quality": 85
  }
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/exports`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Idempotency-Key": "sku-10442-card-v1",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jobId: jobId,
    spec: {
      crop: {
        margin: {
          value: 4,
          unit: "percent",
        },
      },
      placement: {
        canvasWidth: 1200,
        canvasHeight: 1200,
        scalePercent: 90,
      },
      background: "#FFFFFF",
      format: "webp",
      quality: 85,
    },
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, "v1/exports");
request.Headers.Add("Idempotency-Key", "sku-10442-card-v1");
request.Content = JsonContent.Create(new
{
    jobId = jobId,
    spec = new
    {
        crop = new
        {
            margin = new
            {
                value = 4,
                unit = "percent",
            },
        },
        placement = new
        {
            canvasWidth = 1200,
            canvasHeight = 1200,
            scalePercent = 90,
        },
        background = "#FFFFFF",
        format = "webp",
        quality = 85,
    },
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Read an export

GET/v1/exports/{id}

The export's state and, once it succeeded, its files with download URLs signed for this read (15 minutes). Files are deleted 24 hours after the export completed.

Parameters
FieldDescription
id (path)string required
200 OK: ExportResponse
Response 200 fields
FieldDescription
idstring requiredThe export's id.
kindstring requiredvariant or batch_zip. One of variant, batch_zip.
statestring requiredqueued, running, succeeded or failed. One of queued, running, succeeded, failed.
jobIdstring or null requiredA variant's job.
batchIdstring or null requiredA ZIP export's batch.
specobject or null requiredThe format, as stored; null for a ZIP export without variant.
spec.cropobject
spec.crop.thresholdintegerThe alpha (0 to 254) a pixel must exceed to count as the product. Default 8.
spec.crop.marginobjectA distance: whole source pixels, or a percentage (0 to 100) of the content's longer side.
spec.paddingobjectA distance: whole source pixels, or a percentage (0 to 100) of the content's longer side.
spec.padding.valuenumber requiredThe distance: whole pixels, or 0 to 100 percent.
spec.padding.unitstring required One of pixels, percent.
spec.resizeobject
spec.resize.widthintegerThe output's width in pixels.
spec.resize.heightintegerThe output's height in pixels.
spec.resize.modestring One of fit, letterbox. Default "fit".
spec.placementobject
spec.placement.canvasWidthinteger requiredThe canvas's width in pixels.
spec.placement.canvasHeightinteger requiredThe canvas's height in pixels.
spec.placement.scalePercentnumber requiredThe share of the canvas (1 to 100) the product may fill.
spec.placement.anchorstring One of top_left, top, top_right, left, center, right, bottom_left, bottom, bottom_right. Default "center".
spec.backgroundstringAn opaque sRGB colour as #RRGGBB.
spec.silhouettestringAn opaque sRGB colour as #RRGGBB.
spec.formatstring One of png, webp. Default "png".
spec.qualityintegerWebP's quality, 1 to 100. Default 90.
spec.losslessbooleanLossless WebP. Default false.
spec.maxUpscalenumberHow far a resize or placement may enlarge the product: 1 never enlarges. Default 1.
includearray of string or null requiredA ZIP export's files per item.
manifestRequestedboolean or null requiredWhether a ZIP export has a manifest.
errorobject or null requiredWhy it failed.
error.codestring requiredA stable code; see the export error codes. One of file_expired, output_too_large, render_failed, processing_failed.
error.messagestring requiredFor a person to read; may change.
partsarray of object requiredThe files: the variant, or the ZIP parts in order.
parts[].numberinteger requiredIts position, from 1.
parts[].namestring requiredIts file name.
parts[].contentTypestring requiredIts media type.
parts[].sizeinteger requiredBytes.
parts[].sha256string requiredIts SHA-256, hex, to check a download.
parts[].widthinteger or null requiredA variant's width in pixels.
parts[].heightinteger or null requiredA variant's height in pixels.
parts[].expiresAtdate-time requiredWhen the file is deleted.
parts[].expiredboolean requiredThe file is gone.
parts[].urlstring or null requiredThe file, signed for 15 minutes; null once expired.
parts[].urlExpiresAtdate-time or null requiredWhen url stops working.
manifestobject or null requiredA ZIP export's CSV manifest.
manifest.numberinteger requiredIts position, from 1.
manifest.namestring requiredIts file name.
manifest.contentTypestring requiredIts media type.
manifest.sizeinteger requiredBytes.
manifest.sha256string requiredIts SHA-256, hex, to check a download.
manifest.widthinteger or null requiredA variant's width in pixels.
manifest.heightinteger or null requiredA variant's height in pixels.
manifest.expiresAtdate-time requiredWhen the file is deleted.
manifest.expiredboolean requiredThe file is gone.
manifest.urlstring or null requiredThe file, signed for 15 minutes; null once expired.
manifest.urlExpiresAtdate-time or null requiredWhen url stops working.
cachedFromstring or null requiredThe earlier export whose identical variant this one reuses.
createdAtdate-time requiredWhen the export was requested.
startedAtdate-time or null requiredWhen it started running.
completedAtdate-time or null requiredWhen it succeeded or failed.
expiresAtdate-time or null requiredWhen its files are deleted (24 hours after completion).
cURL
curl "https://api.example.com/v1/exports/$EXPORT_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/exports/${exportId}`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>($"v1/exports/{exportId}");

Assets

One stored file by its asset id, with a freshly signed download URL.

Read an asset

GET/v1/assets/{id}

One stored file by the asset id a job's results carry: its type, size, dimensions and expiry, and a download URL signed for this read (15 minutes). Past its retention it answers file_expired.

Parameters
FieldDescription
id (path)string required
200 OK: AssetResponse
Response 200 fields
FieldDescription
idstring requiredThe asset's id.
typestring requiredinput (an original), cutout, mask or preview. One of input, cutout, mask, preview.
contentTypestring requiredThe file's media type.
bytesinteger or null requiredThe file's size; null until known.
widthinteger or null requiredPixels; an input's once validated.
heightinteger or null requiredPixels; an input's once validated.
jobIdstring or null requiredThe job an output belongs to.
createdAtdate-time requiredWhen the asset was created.
expiresAtdate-time requiredWhen the file is deleted: originals after 7 days, outputs 30 days after the job completed.
urlstring or null requiredThe file, signed for this read; null while an input's bytes aren't stored yet.
urlExpiresAtdate-time or null requiredWhen url stops working.
cURL
curl "https://api.example.com/v1/assets/$ASSET_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/assets/${assetId}`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>($"v1/assets/{assetId}");

Credits

Available, reserved and consumed credits, the grants with their expiry, and the credit history.

Read credits

GET/v1/usage

Available, reserved and consumed credits, and every grant in spending order: the earliest expiry is spent first.

200 OK: UsageResponse
Response 200 fields
FieldDescription
availableinteger requiredCredits you can spend now: the active grants' remaining credits.
reservedinteger requiredCredits held by accepted work that hasn't finished.
consumedinteger requiredCredits consumed by succeeded work, over the account's lifetime.
grantsarray of object requiredEvery grant, in spending order (earliest expiry first).
grants[].idstring requiredThe grant's id.
grants[].sourcestring requiredtrial, subscription_period, prepaid_pack or adjustment. One of trial, subscription_period, prepaid_pack, adjustment.
grants[].amountinteger requiredCredits granted.
grants[].remaininginteger requiredCredits left: amount minus reserved, consumed and debited.
grants[].reservedinteger requiredCredits held by unfinished work.
grants[].consumedinteger requiredCredits consumed.
grants[].debitedinteger requiredCredits taken back (a refund, a dispute or an adjustment).
grants[].grantedAtdate-time requiredWhen the credits were granted.
grants[].expiresAtdate-time requiredWhen the remaining credits expire.
grants[].statusstring requiredactive (credits left), exhausted (none left) or expired. One of active, exhausted, expired.
cURL
curl "https://api.example.com/v1/usage" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/usage`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/usage");

List the credit history

GET/v1/usage/history

The account's credit ledger entries of the last 90 days, newest first: grants, reservations, settlements, releases and adjustments.

Parameters
FieldDescription
after (query)stringThe nextCursor of the previous page.
limit (query)integerEntries per page. Default 25.
200 OK: CreditHistoryResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe entries on this page.
items[].idstring requiredThe entry's id.
items[].kindstring requiredgrant, reserve (work accepted), settle (work succeeded), release (work failed or was cancelled) or adjust. One of grant, reserve, settle, release, adjust.
items[].creditsinteger requiredCredits moved: positive, except an adjust that took credits back.
items[].grantIdstring requiredThe grant the entry touched.
items[].grantSourcestring requiredThat grant's source. One of trial, subscription_period, prepaid_pack, adjustment.
items[].jobIdstring or null requiredThe job of a reservation's entry.
items[].batchIdstring or null requiredThat job's batch.
items[].reasonstring or null requiredAn adjustment's reason, written for you.
items[].createdAtdate-time requiredWhen the entry was written.
nextCursorstring or null requiredPass as after for the next page; null on the last.
cURL
curl "https://api.example.com/v1/usage/history" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/usage/history`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/usage/history");

Limits

The account's limits at its tier, read from what enforces them.

Read the limits

GET/v1/limits

The account's limits at its tier, read from what enforces them, so a client can check a file or a batch before submitting it.

200 OK: LimitsResponse
Response 200 fields
FieldDescription
tierstring requiredtrial until the first Standard period or prepaid pack, then paid. One of trial, paid.
batchMaxItemsinteger requiredItems per POST /v1/batches.
inFlightinteger requiredJobs on the GPU at once; more stay queued.
maxUploadBytesinteger requiredBytes per source image, upload or URL.
maxPixelsinteger requiredPixels (width × height) per source image.
maxUrlLengthinteger requiredCharacters of an image URL.
cURL
curl "https://api.example.com/v1/limits" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/limits`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/limits");

Webhooks

Account-owned endpoints that receive signed event deliveries, and their delivery log.

List webhook endpoints

GET/v1/webhook-endpoints

The account's endpoints, each with its newest delivery.

200 OK: WebhookEndpointListResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe endpoints.
items[].idstring requiredThe endpoint's id.
items[].urlstring requiredWhere events are POSTed.
items[].descriptionstring or null requiredYour note about it.
items[].enabledboolean requiredDisabled endpoints receive nothing.
items[].eventsarray of string requiredThe event types it receives. One of job.succeeded, job.failed, job.cancelled, batch.completed.
items[].previousSecretExpiresAtdate-time or null requiredUntil when the secret before the last rotation still signs deliveries.
items[].createdAtdate-time requiredWhen it was registered.
items[].updatedAtdate-time requiredWhen it last changed.
items[].lastDeliveryobject or null requiredIts newest delivery; null before the first.
items[].lastDelivery.statestring requiredpending, delivering, succeeded or failed. One of pending, delivering, succeeded, failed.
items[].lastDelivery.atdate-time requiredWhen it last moved: its last attempt, or when it was queued.
items[].lastDelivery.statusCodeinteger or null requiredThe status the endpoint last answered.
items[].lastDelivery.attemptsinteger requiredAttempts so far; a pending delivery with attempts is a retry.
cURL
curl "https://api.example.com/v1/webhook-endpoints" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/webhook-endpoints`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/webhook-endpoints");

Register a webhook endpoint

POST/v1/webhook-endpoints

Registers an https URL that receives the account's events, signed with a secret shown in this response only. The URL must be public: private, loopback, link-local and metadata addresses are refused, at registration and again on every delivery. Without events it receives every type.

Request body
FieldDescription
urlstring requiredA public https URL on port 443, at most 2,048 characters.
descriptionstringA note for you, at most 256 characters on one line.
eventsarray of stringThe event types to receive; omitted, every type known today. One of job.succeeded, job.failed, job.cancelled, batch.completed.
201 Created: CreatedWebhookEndpointResponse
Response 201 fields
FieldDescription
idstring requiredThe endpoint's id.
urlstring requiredWhere events are POSTed.
descriptionstring or null requiredYour note about it.
enabledboolean requiredDisabled endpoints receive nothing.
eventsarray of string requiredThe event types it receives. One of job.succeeded, job.failed, job.cancelled, batch.completed.
previousSecretExpiresAtdate-time or null requiredUntil when the secret before the last rotation still signs deliveries.
createdAtdate-time requiredWhen it was registered.
updatedAtdate-time requiredWhen it last changed.
secretstring requiredThe signing secret, whsec_ followed by base64.
cURL
curl -X POST "https://api.example.com/v1/webhook-endpoints" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "url": "https://integrations.example.com/webhooks/cutouts",
  "description": "Catalogue import",
  "events": [
    "job.succeeded",
    "job.failed",
    "batch.completed"
  ]
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/webhook-endpoints`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://integrations.example.com/webhooks/cutouts",
    description: "Catalogue import",
    events: [
      "job.succeeded",
      "job.failed",
      "batch.completed",
    ],
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, "v1/webhook-endpoints");
request.Content = JsonContent.Create(new
{
    url = "https://integrations.example.com/webhooks/cutouts",
    description = "Catalogue import",
    events = new[]
    {
        "job.succeeded",
        "job.failed",
        "batch.completed",
    },
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Change a webhook endpoint

PATCH/v1/webhook-endpoints/{id}

Changes the fields sent; the others stay. A new URL is checked again.

Parameters
FieldDescription
id (path)string required
Request body
FieldDescription
urlstringA new public https URL.
descriptionstringA new note; an empty string clears it.
enabledbooleanfalse stops deliveries; true resumes them.
eventsarray of stringThe event types to receive. One of job.succeeded, job.failed, job.cancelled, batch.completed.
200 OK: WebhookEndpointResponse
Response 200 fields
FieldDescription
idstring requiredThe endpoint's id.
urlstring requiredWhere events are POSTed.
descriptionstring or null requiredYour note about it.
enabledboolean requiredDisabled endpoints receive nothing.
eventsarray of string requiredThe event types it receives. One of job.succeeded, job.failed, job.cancelled, batch.completed.
previousSecretExpiresAtdate-time or null requiredUntil when the secret before the last rotation still signs deliveries.
createdAtdate-time requiredWhen it was registered.
updatedAtdate-time requiredWhen it last changed.
cURL
curl -X PATCH "https://api.example.com/v1/webhook-endpoints/$ENDPOINT_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "enabled": false
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/webhook-endpoints/${endpointId}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    enabled: false,
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Patch, $"v1/webhook-endpoints/{endpointId}");
request.Content = JsonContent.Create(new
{
    enabled = false,
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Delete a webhook endpoint

DELETE/v1/webhook-endpoints/{id}

Deletes the endpoint and its delivery log; pending deliveries are not sent.

Parameters
FieldDescription
id (path)string required

204 No Content, with no body.

cURL
curl -X DELETE "https://api.example.com/v1/webhook-endpoints/$ENDPOINT_ID" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/webhook-endpoints/${endpointId}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
C#
using var response = await http.DeleteAsync($"v1/webhook-endpoints/{endpointId}");
response.EnsureSuccessStatusCode();

List an endpoint's deliveries

GET/v1/webhook-endpoints/{id}/deliveries

The endpoint's deliveries, newest first, each with its attempts and the event data as sent.

Parameters
FieldDescription
id (path)string required
cursor (query)stringThe nextCursor of the previous page.
limit (query)integerDeliveries per page. Default 20.
200 OK: WebhookDeliveryPageResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe deliveries on this page.
items[].idstring requiredThe delivery's id.
items[].eventIdstring requiredThe event's id, sent as webhook-id.
items[].eventTypestring requiredThe event's type. One of job.succeeded, job.failed, job.cancelled, batch.completed.
items[].statestring requiredpending, delivering, succeeded or failed (out of attempts, refused with a 4xx, or not sendable). One of pending, delivering, succeeded, failed.
items[].attemptsinteger requiredAttempts so far.
items[].lastStatusCodeinteger or null requiredThe status the endpoint last answered.
items[].lastErrorstring or null requiredWhy the last attempt got no answer: timeout, unreachable, unsafe_url, endpoint_disabled, endpoint_deleted or internal_error.
items[].lastAttemptAtdate-time or null requiredWhen it was last tried.
items[].nextAttemptAtdate-time or null requiredWhen it is tried next; only while a retry is pending.
items[].createdAtdate-time requiredWhen the event was published to the endpoint.
items[].completedAtdate-time or null requiredWhen it succeeded or failed for good.
items[].dataJobEventData or BatchEventData requiredThe event's data as sent: JobEventData for job events, BatchEventData for batch.completed.
items[].attemptLogarray of object requiredEvery attempt, oldest first.
items[].attemptLog[].atdate-time requiredWhen the attempt was made.
items[].attemptLog[].statusCodeinteger or null requiredThe status the endpoint answered; null when it answered none.
items[].attemptLog[].errorstring or null requiredWhy there was no answer: timeout, unreachable, unsafe_url, endpoint_disabled, endpoint_deleted or internal_error; null when it answered.
items[].attemptLog[].latencyMillisecondsinteger requiredHow long the attempt took.
nextCursorstring or null requiredPass as cursor for the next page; null on the last.
cURL
curl "https://api.example.com/v1/webhook-endpoints/$ENDPOINT_ID/deliveries" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/webhook-endpoints/${endpointId}/deliveries`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>($"v1/webhook-endpoints/{endpointId}/deliveries");

Rotate the signing secret

POST/v1/webhook-endpoints/{id}/rotate-secret

Issues a new signing secret, shown in this response only. For 24 hours deliveries carry a signature with each secret, so a receiver can switch without missing one.

Parameters
FieldDescription
id (path)string required
200 OK: RotatedWebhookSecretResponse
Response 200 fields
FieldDescription
idstring requiredThe endpoint's id.
secretstring requiredThe new signing secret, whsec_ followed by base64.
previousSecretExpiresAtdate-time or null requiredUntil when the previous secret still signs deliveries (24 hours).
cURL
curl -X POST "https://api.example.com/v1/webhook-endpoints/$ENDPOINT_ID/rotate-secret" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/webhook-endpoints/${endpointId}/rotate-secret`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var response = await http.SendAsync(new HttpRequestMessage(HttpMethod.Post, $"v1/webhook-endpoints/{endpointId}/rotate-secret"));
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

Reports

Report a poor result on a succeeded job; we review it and may restore its credit.

List a job's reports

GET/v1/jobs/{id}/reports

The job's issue reports, newest first.

Parameters
FieldDescription
id (path)string required
200 OK: JobIssueReportsResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe reports.
items[].idstring requiredThe report's id.
items[].jobIdstring requiredThe reported job.
items[].batchIdstring or null requiredThe job's batch.
items[].reasonstring requirededges, missing_part, background_left or other. One of edges, missing_part, background_left, other.
items[].notestring or null requiredYour note.
items[].statestring requiredopen, resolved_restored (the credit was restored) or resolved_declined. One of open, resolved_restored, resolved_declined.
items[].createdAtdate-time requiredWhen it was reported.
items[].resolvedAtdate-time or null requiredWhen it was resolved.
items[].resolutionReasonstring or null requiredOur answer, written for you.
cURL
curl "https://api.example.com/v1/jobs/$JOB_ID/reports" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/jobs/${jobId}/reports`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>($"v1/jobs/{jobId}/reports");

Report a poor result

POST/v1/jobs/{id}/reports

Reports a problem with a succeeded job's cutout. We review it and may restore the job's credit; a restored credit shows in the credit history. One open report per job.

Parameters
FieldDescription
id (path)string required
Request body
FieldDescription
reasonstring requirededges (cut into the product or a fringe left), missing_part, background_left or other. One of edges, missing_part, background_left, other.
notestringPlain text, at most 1,000 characters.
201 Created: IssueReportResponse
Response 201 fields
FieldDescription
idstring requiredThe report's id.
jobIdstring requiredThe reported job.
batchIdstring or null requiredThe job's batch.
reasonstring requirededges, missing_part, background_left or other. One of edges, missing_part, background_left, other.
notestring or null requiredYour note.
statestring requiredopen, resolved_restored (the credit was restored) or resolved_declined. One of open, resolved_restored, resolved_declined.
createdAtdate-time requiredWhen it was reported.
resolvedAtdate-time or null requiredWhen it was resolved.
resolutionReasonstring or null requiredOur answer, written for you.
cURL
curl -X POST "https://api.example.com/v1/jobs/$JOB_ID/reports" \
  -H "Authorization: Bearer $MASKYARD_API_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "reason": "edges",
  "note": "The strap's edge is cut off."
}
EOF
TypeScript
const response = await fetch(`https://api.example.com/v1/jobs/${jobId}/reports`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    reason: "edges",
    note: "The strap's edge is cut off.",
  }),
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
using var request = new HttpRequestMessage(HttpMethod.Post, $"v1/jobs/{jobId}/reports");
request.Content = JsonContent.Create(new
{
    reason = "edges",
    note = "The strap's edge is cut off.",
});
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<JsonElement>();

List reports

GET/v1/reports

The account's issue reports, newest first.

Parameters
FieldDescription
after (query)stringThe nextCursor of the previous page.
limit (query)integerReports per page. Default 25.
state (query)stringOnly reports in this state. One of open, resolved_restored, resolved_declined.
200 OK: IssueReportListResponse
Response 200 fields
FieldDescription
itemsarray of object requiredThe reports on this page.
items[].idstring requiredThe report's id.
items[].jobIdstring requiredThe reported job.
items[].batchIdstring or null requiredThe job's batch.
items[].reasonstring requirededges, missing_part, background_left or other. One of edges, missing_part, background_left, other.
items[].notestring or null requiredYour note.
items[].statestring requiredopen, resolved_restored (the credit was restored) or resolved_declined. One of open, resolved_restored, resolved_declined.
items[].createdAtdate-time requiredWhen it was reported.
items[].resolvedAtdate-time or null requiredWhen it was resolved.
items[].resolutionReasonstring or null requiredOur answer, written for you.
nextCursorstring or null requiredPass as after for the next page; null on the last.
cURL
curl "https://api.example.com/v1/reports?state=open" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/reports?state=open`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/reports?state=open");

Account

The account's status and, once deleted, the deletion's progress.

Read the account

GET/v1/account

The account's status and, once its owner deleted it, the deletion's progress.

200 OK: AccountResponse
Response 200 fields
FieldDescription
idstring requiredThe account's id.
statusstring requiredactive; restricted_for_review after a refund or dispute took back more than was left (no new processing until we review it); closed once deleted. One of active, restricted_for_review, closed.
createdAtdate-time requiredWhen the account was created.
deletionobject or null requiredThe deletion's progress; null unless the account was deleted.
deletion.idstring requiredThe job's, batch's or account's id.
deletion.statestring requireddeleting or deleted.
deletion.requestedAtdate-time requiredWhen the deletion was asked for.
deletion.completedAtdate-time or null requiredWhen the last file was deleted.
cURL
curl "https://api.example.com/v1/account" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/account`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/account");

Billing

The subscription, recent purchases and any pause on new processing.

Read billing

GET/v1/billing

The subscription, recent purchases and, when new processing is paused, why.

200 OK: BillingResponse
Response 200 fields
FieldDescription
subscriptionobject or null requiredThe Standard subscription; null without one.
subscription.offerstring requiredstandard. One of standard, prepaid_pack.
subscription.statusstring requiredpending, active, past_due, on_hold, paused, cancelled, failed, expired or unknown. One of pending, active, past_due, on_hold, paused, cancelled, failed, expired, unknown.
subscription.currentPeriodStartdate-time requiredThe paid period's start.
subscription.currentPeriodEnddate-time requiredThe paid period's end; its credits expire then.
subscription.cancelAtPeriodEndboolean requiredCancelled: it stops at the period's end.
subscription.renewsAtdate-time or null requiredThe next charge; null once nothing renews.
subscription.endsAtdate-time or null requiredWhen the subscription stops or stopped.
purchasesarray of object requiredRecent purchases, newest first.
purchases[].idstring requiredThe purchase's id.
purchases[].offerstring requiredstandard or prepaid_pack. One of standard, prepaid_pack.
purchases[].statusstring requiredpending, succeeded, failed or cancelled. One of pending, succeeded, failed, cancelled.
purchases[].amountinteger requiredThe amount paid, in minor units.
purchases[].currencystring requiredISO 4217, such as USD.
purchases[].purchasedAtdate-time requiredWhen it was bought.
purchases[].periodStartdate-time or null requiredA subscription payment's period start.
purchases[].periodEnddate-time or null requiredA subscription payment's period end.
purchases[].refundedAmountinteger requiredThe amount refunded, in minor units.
purchases[].disputedboolean requiredA dispute was opened.
purchases[].disputeStatestring requirednone, open, won or lost.
purchases[].disputeOpenedAtdate-time or null requiredWhen the dispute was opened.
restrictionobject or null requiredWhy new processing is paused; null unless it is.
restriction.categorystring requiredrefund, dispute or review.
restriction.sincedate-time requiredWhen the restriction began.
cURL
curl "https://api.example.com/v1/billing" \
  -H "Authorization: Bearer $MASKYARD_API_KEY"
TypeScript
const response = await fetch(`https://api.example.com/v1/billing`, {
  headers: {
    Authorization: `Bearer ${process.env.MASKYARD_API_KEY}`,
  },
});
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const result = await response.json();
C#
var result = await http.GetFromJsonAsync<JsonElement>("v1/billing");