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

> ## Agent Instructions
> The base URL is https://api.sudomock.com.
> Authenticate every request with the x-api-key header. Keys begin with sm_.
> A render returns the finished image at data.print_files[0].export_path. A request sent with is_async true returns a job_id to poll at GET /api/v1/jobs/{job_id}.
> Prefer the official SDKs over hand-written HTTP calls: npm install sudomock for Node, pip install sudomock for Python.

# Check and fix pattern seams

> Find a seam in a tile and repair it before you render.

A tile repeats cleanly only when its right edge runs on into its left edge and
its bottom into its top. Check seams tells you whether that holds, free and in
the same call. Fix seams repairs a tile that does not, as a job. Both work the
same way whether the pattern goes onto a PSD smart object or a photo mockup.

Reach for them when you need to:

* **Catch a line before a customer does**: a seam repeats across every copy of
  the tile, so one bad join becomes a grid of them on the product.
* **Repair a file you cannot redraw**: a customer upload or a stock tile that
  almost repeats.
* **Run a catalogue unattended**: check every pattern in a batch and only stop
  for the ones that need a decision.

## When a check applies

A check looks at the joins between copies, so it applies when the copies touch:
`tile` is `true` and `tile_spacing` is `0` or left out. With a gap, the copies
never meet and there is no seam to find.

The fit mode decides what to send. With `fill`, check the file as it is. With
`crop`, send `crop_aspect`, the tile's width divided by its height, and the
check runs on the same cut the render makes. With `fit`, the artwork fills the
tile only when its proportions match the tile's; when they differ, each copy
sits in its own margin and there is nothing to check.
[Fit and blend modes](https://sudomock.com/docs/concepts/fit-and-blend-modes.md) covers the three modes.

## Check a tile

```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}}
curl -X POST "https://api.sudomock.com/api/v1/check-seams" \
  -H "x-api-key: sm_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/pattern-tile.png",
    "crop_aspect": 1.5
  }'
```

`data.status` is the answer to act on.

| Status | What it means | What to do |
| - | - | - |
| `seamless` | The copies meet with no line. | Render. |
| `faint_seam` | A slight line that can show on close inspection. | Render, or fix it for a print that is seen up close. |
| `visible_seam` | A line most people will notice. | Fix it, or ask for a new file. |

`data.seams` names each join that is not seamless and the pixel stretches
where it breaks, so you can show a person exactly where to look.
[Check seams](https://sudomock.com/docs/api-reference/patterns/check-seams.md) lists every field.

## Fix a tile

**1. Read fixable**

The check already says whether a fix will be accepted. `fixable` is `false`
with `unfixable_reason` set to `transparent_edges` when the tile has
transparent pixels along its edges, and to `too_large` when it is above the
size a fix takes. A fix refuses both before anything is charged.

**2. Start the fix**

Send the same body to `POST /api/v1/fix-seams`, with an
`Idempotency-Key` header. The call answers `202` with a `job_id`.

```bash cURL theme={"theme":{"light":"github-light","dark":"vesper"}}
curl -X POST "https://api.sudomock.com/api/v1/fix-seams" \
  -H "x-api-key: sm_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7c1e2f0a-tile-42" \
  -d '{
    "url": "https://example.com/pattern-tile.png",
    "crop_aspect": 1.5
  }'
```

**3. Follow the job**

Poll [Retrieve a single job](https://sudomock.com/docs/api-reference/jobs/retrieve-a-single-job.md)
every few seconds until `status` is `succeeded`, `failed` or `cancelled`.
`stage` moves forward through `queued`, `fixing` and `finishing`, so a
progress line has something true to say.

```js Node.js theme={"theme":{"light":"github-light","dark":"vesper"}}
const api = "https://api.sudomock.com/api/v1";
const headers = { "x-api-key": process.env.SUDOMOCK_API_KEY };
const done = ["succeeded", "failed", "cancelled"];

async function waitForFix(jobId) {
  for (;;) {
    const res = await fetch(`${api}/jobs/${jobId}`, { headers });
    const job = await res.json();
    if (done.includes(job.status)) return job;
    await new Promise((r) => setTimeout(r, 3000));
  }
}
```

**4. Render with the result**

Put `result_url` in the render as the tile's artwork, with the same `fit`
and `size` you checked with.

A finished fix reads like this:

```json Response theme={"theme":{"light":"github-light","dark":"vesper"}}
{
  "job_id": "8d2b6c1e-4f3a-4b7d-9e05-2a6c7f1b3d48",
  "kind": "seam_fix",
  "status": "succeeded",
  "stage": "finishing",
  "result_url": "https://cdn.sudomock.com/mockup-assets/seam-fixed/9c4e.png",
  "alternative_url": null,
  "result_status": "seamless",
  "changes": "edges",
  "credits_charged": 60,
  "error": null
}
```

## Read the result

`result_status` is a free check of the repaired tile. `changes` reads `edges` when only the area around the
joins changed, and `whole_tile` when the tile was rebuilt as a whole and fine
detail can look softer. When `alternative_url` is set, a second repair also
passed; show both to a person when they are choosing.

A failed job carries `TILE_NOT_FIXABLE` or `SEAM_FIX_FAILED`, and its credits
are returned. On `TILE_NOT_FIXABLE`, `details.reason` is `not_a_pattern_tile`
when the image is not a repeating tile and `no_clean_result` when no clean
repeat could be made from it. [Errors](https://sudomock.com/docs/errors.md#pattern-error-codes) says which
one is worth a retry.

## Take the result by webhook

Instead of polling, subscribe an endpoint to `seam_fix.succeeded` and
`seam_fix.failed`. The delivery carries `result_url` and `alternative_url`
beside the usual envelope, and [Webhooks](https://sudomock.com/docs/webhooks/overview.md) covers
registering the endpoint and checking the signature.

## Reuse a tile you already fixed

The repaired files are kept. A later check of the same image with the same
`crop_aspect` returns your latest successful fix in `previous_fix`, with its
`job_id`, `result_url` and `alternative_url`, so you can reuse the repair you
bought instead of buying it again.

## A warning on the render

A render that repeats a tile with the copies touching adds `TILE_SEAM_VISIBLE`
to its `warnings` when that tile was checked before and showed a visible seam.
The warning is advice only, and the render still succeeds. A tile that was
never checked carries no warning, so check it first.

## What it costs

A check costs nothing. A fix is charged at the weight in [the credit
table](https://sudomock.com/docs/knowledge-base/in-what-order-credits-are-spent.md#what-each-operation-weighs),
taken when the job is accepted and returned if it fails. Without a plan, the
price per fix is on [Pay as you go](https://sudomock.com/docs/knowledge-base/how-pay-as-you-go-works.md).
Repeat checks of the same tile do not count toward the [seam check
rate](https://sudomock.com/docs/api-reference/usage-limits.md#seam-checks).

> [card] [Check seams](https://sudomock.com/docs/api-reference/patterns/check-seams.md)
>
> Every field of the check request and answer.

> [card] [Fix seams](https://sudomock.com/docs/api-reference/patterns/fix-seams.md)
>
> The fix job, its limits and its results.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.