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

# Apply an edit operation

> Submit Rework, Layer, Accompany, Extend, Restyle or Separate.

Task IDs: `repaint` = Rework, `lego` = Layer, `complete` = Accompany, `extend` = Extend, `cover` = Restyle, `extract` = Separate.

Rework needs positive `repaintingStart`/`repaintingEnd`. Layer needs `trackName`. Layer and Accompany require `base`. Extend needs a longer `audioDuration`. Restyle needs `coverStrength`. See [editing operations](/dev/guides/edit/overview).

## Headers and parameters

<ParamField header="Authorization" type="string" required>
  `Bearer $SESSION_TOKEN`. Use the complete token from your active [Rawchunks session](/dev/guides/payments).
</ParamField>

<ParamField header="x-session-user-address" type="string" required>
  Selected account address. Required for owner-scoped reads and writes. It identifies the account; your product must authenticate its own users.
</ParamField>

<ParamField header="x-network-id" type="string">
  Session network in CAIP-2 form, for example eip155:8453.
</ParamField>

## JSON body

<ParamField body="songId" type="string" required>
  Opaque ID returned by the API. Minimum length: `1`.
</ParamField>

<ParamField body="stemId" type="string">
  Optional target stem in this song. Omit to use the master.
</ParamField>

<ParamField body="userAddress" type="string" required>
  Wallet address for the selected account. Use the same address as the session owner. Minimum length: `10`.
</ParamField>

<ParamField body="srcAudioUrl" type="string">
  Optional source override, for example the url from Upload source. Use an HTTP(S) URL.
</ParamField>

<ParamField body="modelQuality" type="string">
  Select a mode listed for this task by GET /api/options. Defaults to base. Layer and Accompany require base. Values: `turbo`, `sft`, `base`.
</ParamField>

<ParamField body="modelVariant" type="string">
  Alternative to modelQuality. If both are sent they must match. Values: `turbo`, `sft`, `base`.
</ParamField>

<ParamField body="seed" type="integer">
  Optional seed. Omit for a random seed; this is not a guarantee of byte-identical audio. Range: `0` to `9007199254740991`.
</ParamField>

<ParamField body="bpm" type="number">
  Tempo in beats per minute. Range: `30` to `300`.
</ParamField>

<ParamField body="keyScale" type="string">
  Key ID from GET /api/options.
</ParamField>

<ParamField body="vocalLanguage" type="string">
  Language ID from GET /api/options.
</ParamField>

<ParamField body="prompt" type="string" />

<ParamField body="lyrics" type="string" />

<ParamField body="repaintMode" type="string">
  Values: `conservative`, `balanced`, `aggressive`.
</ParamField>

<ParamField body="repaintStrength" type="number">
  Range: `0` to `1`.
</ParamField>

<ParamField body="repaintLatentCrossfadeFrames" type="integer">
  Transition control in latent frames. Minimum: `0`.
</ParamField>

<ParamField body="repaintWavCrossfadeSec" type="number">
  Requested transition length in seconds. Minimum: `0`.
</ParamField>

<ParamField body="globalCaption" type="string">
  Description of the overall song.
</ParamField>

<ParamField body="trackName" type="string">
  Instrument name. Required by the Layer service. Minimum length: `1`.
</ParamField>

<ParamField body="trackClasses" type="string[]" />

<ParamField body="audioDuration" type="number">
  Minimum: `5`.
</ParamField>

<ParamField body="legoContextTrackIds" type="string[]" />

<ParamField body="task" type="string" required>
  Values: `repaint`, `lego`, `complete`, `extend`, `cover`, `extract`.
</ParamField>

<ParamField body="repaintingStart" type="number">
  Minimum: `0`.
</ParamField>

<ParamField body="repaintingEnd" type="number">
  Minimum: `0`.
</ParamField>

<ParamField body="coverStrength" type="number">
  Range: `0` to `1`.
</ParamField>

<ParamField body="coverNoiseStrength" type="number">
  Range: `0` to `1`.
</ParamField>

<ParamField body="stemType" type="string" default={"all"} />

## Response (202)

Accepted; follow the returned task.

<ResponseField name="taskId" type="string" required />

<ResponseField name="songId" type="string" required />

<ResponseField name="stemId" type="string" />

<ResponseField name="task" type="string" required>
  Values: `repaint`, `lego`, `complete`, `extend`, `cover`, `extract`.
</ResponseField>

<ResponseField name="status" type="string" required>
  Values: `pending`, `processing`, `ready`, `error`.
</ResponseField>

<ResponseField name="stems" type="object[]">
  <Expandable title="Properties">
    <ResponseField name="id" type="string" required />

    <ResponseField name="song_id" type="string" required />

    <ResponseField name="name" type="string" required />

    <ResponseField name="url" type="string" required />

    <ResponseField name="volume" type="number">
      Linear gain, 1 is unity. Minimum: `0`.
    </ResponseField>

    <ResponseField name="pan" type="number">
      Range: `-1` to `1`.
    </ResponseField>

    <ResponseField name="is_muted" type="boolean" />

    <ResponseField name="is_solo" type="boolean" />

    <ResponseField name="waveform_peaks_url" type="string | null" />

    <ResponseField name="created_at" type="string" />
  </Expandable>
</ResponseField>

Budget headers use six-decimal USDC atomic units. See [session payments](/dev/guides/payments#track-or-end-a-session).

## Errors

Failed JSON responses contain an `error` string. Check the HTTP status before reading a successful result. See [job handling](/dev/guides/jobs) for interrupted or uncertain submissions.

| Status | Meaning |
| - | - |
| `400` | Invalid request. |
| `401` | Invalid or expired session token. |
| `402` | Payment required or insufficient session budget. |
| `403` | Account does not match resource. |
| `404` | Resource not found. |
| `409` | Resource conflict; reload state or open an editable version. |
| `500` | Request failed. |

<RequestExample>
  ```bash cURL theme={null}
  curl --fail-with-body -X POST "$RAWCHUNKS_API/api/editing/apply" \
    -H "Authorization: Bearer $SESSION_TOKEN" \
    -H "x-network-id: $NETWORK" \
    -H "x-session-user-address: $USER_ADDRESS" \
    -H "Content-Type: application/json" \
    --data "$(jq -nc --arg user "$USER_ADDRESS" --arg song "$SONG_ID" '{
    "songId": $song,
    "userAddress": $user,
    "task": "complete",
    "prompt": "Acoustic guitar and restrained drums",
    "modelQuality": "base",
    "trackClasses": [
      "guitar",
      "drums"
    ]
  }')"
  ```
</RequestExample>

<ResponseExample>
  ```json 202 theme={null}
  {
    "songId": "sng-example",
    "taskId": "task-example",
    "status": "pending",
    "task": "repaint"
  }
  ```
</ResponseExample>


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