# Initialize the shared app source once

Initialize an app's source head from an imported source. Subsequent changes must use draft apply. Repeating the initial request before any apply is safe.

`POST /api/platform/v1/apps/{appId}/source-head/initialize`

Required permission: `project:update`.

## Parameters

| Name | In | Type | Required | Description |

| --- | --- | --- | --- | --- |

| `appId` | path | `string` | Yes | — |

| `Idempotency-Key` | header | `string` | No | Required for service credentials. Retry the same request with the same key. |

## Request body

| Field | Type | Required | Constraints | Description |
| --- | --- | --- | --- | --- |
| `sourceId` | `string` | Yes | min length 1, max length 128 | — |

```json
{
  "sourceId": "src_saved"
}
```

## Example request

```bash
curl --request POST \
  --url https://api.hoplite.sh/api/platform/v1/apps/appId/source-head/initialize \
  --header "X-Api-Key: $HOPLITE_API_KEY" \
  --header "Idempotency-Key: $HOPLITE_OPERATION_ID" \
  --header 'Content-Type: application/json' \
  --data '{
  "sourceId": "src_saved"
}'
```

## 200 response

Success

Content type: `application/json`. Response type: `object`.

| Field | Type | Required | Constraints | Description |
| --- | --- | --- | --- | --- |
| `ok` | `boolean` | Yes | true | — |
| `head` | `object` | Yes | — | — |
| `head.orgId` | `string` | Yes | — | — |
| `head.projectId` | `string` | Yes | — | — |
| `head.sourceId` | `string` | Yes | — | — |
| `head.revision` | `integer` | Yes | min -9007199254740991, max 9007199254740991 | — |
| `head.updatedAt` | `string` | Yes | — | — |

```json

```

## Status codes

- `200` — Success

- `400` — Invalid request

- `401` — Authentication required

- `403` — Permission, app scope or entitlement denied

- `404` — App, source or thread not found

- `409` — Idempotency conflict or request in progress

- `413` — Request too large

- `503` — Source storage or execution unavailable