> ## 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.

# Fitting and colour

> Keep new text in its box and recolour it per render.

A replacement is rarely the same length as the text it stands in for, and the
colour a designer set is not always the colour you want to ship. Both are
arguments on the render call, along with the outline around the text and each
styled run inside it.

Use these overrides when you need to:

* **Personalise a run**: keep a customer name inside the box the designer drew
  for it, whatever its length.
* **Ship a colourway**: send the same template out in a new colour without
  opening the source file.
* **Change one run**: replace part of a line that mixes styles and leave the
  rest as designed.

<Note>
  A layer's uuid, and the fields that say which overrides it takes, come from
  the upload response. [Text layers](/docs/text/text-layers) covers it and lists
  every error and warning code.
</Note>

## Send an override with the render call

`fit` decides what happens when the new text is wider than the layer's area,
`color` and `stroke_color` set the colour of the text and of the outline around
it, `group_layers` recolours an outline the enclosing group owns, and
`segments` replaces one run inside a layer that mixes styles. Each tab below
carries one of them, and the highlighted lines carry the change.

<CodeGroup>
  ```json Fit and align {7-8} theme={"theme":{"light":"github-light","dark":"vesper"}}
  {
    "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",
    "text_layers": [
      {
        "uuid": "b7f2c1a0-9e34-4d21-8f0a-1c2b3d4e5f60",
        "text": "Congratulations on ten remarkable years",
        "fit": "shrink",
        "vertical_align": "center"
      }
    ]
  }
  ```

  ```json Recolour text and outline {7-8} theme={"theme":{"light":"github-light","dark":"vesper"}}
  {
    "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",
    "text_layers": [
      {
        "uuid": "b7f2c1a0-9e34-4d21-8f0a-1c2b3d4e5f60",
        "text": "SUMMER SALE",
        "color": "#C0392B",
        "stroke_color": "#FFFFFF"
      }
    ]
  }
  ```

  ```json Recolour a group outline {3-8} theme={"theme":{"light":"github-light","dark":"vesper"}}
  {
    "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",
    "group_layers": [
      {
        "uuid": "9d7e4b18-3a65-4c21-8f90-2b6d7e1a5c43",
        "stroke_color": "#1A1A1A"
      }
    ]
  }
  ```

  ```json Change one styled run {6-9} theme={"theme":{"light":"github-light","dark":"vesper"}}
  {
    "mockup_uuid": "c315f78f-d2c7-4541-b240-a9372842de94",
    "text_layers": [
      {
        "uuid": "b7f2c1a0-9e34-4d21-8f0a-1c2b3d4e5f60",
        "segments": [
          { "index": 0, "text": "Jane " },
          { "index": 1, "text": "SMITH" }
        ]
      }
    ]
  }
  ```
</CodeGroup>

## Response format

A render answers with the files it produced and, when something needed
attention, a `warnings` array. A `shrink` that actually reduced a layer adds
`TEXT_FIT_SHRUNK` for that layer, so the response alone tells you the text came
out smaller than designed. A render that touches only text and group layers
leaves `smart_object_uuid` empty.

```json Render response with a fit warning {12-17} theme={"theme":{"light":"github-light","dark":"vesper"}}
{
  "success": true,
  "data": {
    "print_files": [
      {
        "export_path": "https://cdn.sudomock.com/renders/....webp",
        "smart_object_uuid": ""
      }
    ],
    "render_uuid": "4b7c9e10-33aa-4c52-8f6d-1e9b0c7a2d85"
  },
  "warnings": [
    {
      "code": "TEXT_FIT_SHRUNK",
      "message": "Text was scaled down to fit its area."
    }
  ]
}
```

## Configuration

<ParamField body="text_layers[].fit" type="string" default="overflow">
  What happens when the replacement text is wider than the layer's area. This
  is the text layer's own value, not `asset.fit` on a smart object.

  * `overflow`: the text keeps its size and may extend past the area.
  * `clip`: the text keeps its size and is cut to what fits.
  * `shrink`: the text is scaled down so it stays inside the area.
</ParamField>

<ParamField body="text_layers[].vertical_align" type="string" default="top">
  Where smaller text sits in the room it leaves behind. It takes effect only
  when `shrink` actually reduced a single-style point-text layer.

  * `top`: the text stays where the designer placed it.
  * `center`: the text sits in the vertical middle.
  * `bottom`: the text sits on the bottom edge.

  For user-supplied names and titles, `shrink` with `center` is the pairing
  that keeps a personalised run looking composed at any length.
</ParamField>

<ParamField body="text_layers[].color" type="string">
  A hex string for the colour you actually see. Designers often give a layer
  its final colour through a colour effect rather than the fill, so your value
  goes to whichever one defines the visible colour. `has_color_overlay` in the
  upload response is true when the colour comes from an effect.
</ParamField>

<ParamField body="text_layers[].stroke_color" type="string | array">
  The colour of an outline the layer owns, keeping its width and placement.
  `has_stroke_effect` in the upload response is true when the layer has at
  least one, and `stroke_count` gives how many.

  * A hex string recolours the front outline.
  * A front-to-back list recolours a stack, one entry per outline.
  * `null` in any position keeps that outline as designed.
</ParamField>

<ParamField body="text_layers[].segments" type="object[]">
  The styled runs to replace in a layer that mixes styles, which the upload
  response marks with `segment_count` above 1 and lists under `segments`. Send
  only the runs you want to change. Every run keeps its own font, size and
  colour, and a run you leave out keeps its original text.

  * `index`: the position of the run, read from the upload response.
  * `text`: the replacement wording for that run.
</ParamField>

<ParamField body="group_layers[].stroke_color" type="string">
  A hex string for an outline owned by an enclosing group, which recolours the
  outline around everything inside that group. Take the group uuid from the
  layer's `enclosing_group_layers`.
</ParamField>

## Limitations

When overriding text layers, keep in mind:

* `fit` applies to single-style layers. Paragraph, or box, layers wrap on their
  own and layers that mix styles keep their own layout.
* A gradient effect covering the text returns `TEXT_COLOR_HIDDEN_BY_EFFECT`,
  because the requested colour may not be visible in the result.
* A layer with no outline of its own accepts `stroke_color`, returns
  `TEXT_STROKE_NOT_PRESENT` and ignores it. Stack entries past `stroke_count`
  are ignored the same way.
* Sending `text` to a layer that mixes styles returns `TEXT_SEGMENTS_REQUIRED`,
  and sending `segments` to a single-style layer returns
  `TEXT_SEGMENTS_UNSUPPORTED`. Read `segment_count` once and branch on it,
  rather than guessing per layer.
* A layer takes 1 to 32 segment entries of 1 to 200 characters each, and its
  combined segment text is capped at 500 characters.
* One render carries at most 200 segment overrides across its text layers, and
  at most 50 group overrides.

## API reference

For the complete request and response, see the [Render a PSD
mockup](/docs/api-reference/psd-mockups/render-a-psd-mockup) API reference. The
upload fields named above come from [Create a mockup from a
PSD](/docs/api-reference/psd-mockups/create-a-mockup-from-a-psd).

<CardGroup cols={2}>
  <Card title="Text layers" icon="type" href="/docs/text/text-layers">
    The upload response, render overrides, and what renders from a text layer.
  </Card>

  <Card title="Fonts" icon="book-open" href="/docs/text/fonts">
    Pick a catalogue font, or upload your own.
  </Card>
</CardGroup>
