# Register an executor

> Source: https://docs.clonepartner.com/api-reference/executors/executor-register/

`POST /api/executors/register`

Called by an executor on startup (and re-called after a control-plane
restart when its first heartbeat 404s). The control plane renews the
leases of any `runIds` included so liveness is re-established
immediately rather than waiting for the next heartbeat cycle.

**Operation ID:** `executorRegister`

## Authentication

- **ExecutorKeyAuth** (`http bearer`)
  Shared executor secret (`ENVOY_EXECUTOR_KEY`). Used by internal executor-to-control-plane routes (registration, heartbeat, completion/log callbacks).
  **Internal executor authentication:** use the documented shared executor key. Do not replace it with a user API key.

## Request body

The request body is required.

### `application/json`

- Type: `object`
- Properties:
  - `url` (`string`, `required`) — Executor base URL (matches `runs.executor_id`).
  - `maxConcurrent` (`integer`, `required`) — Concurrency capacity.
  - `labels` (`object`) — Optional labels used for dispatch selection.
    - Description: Optional labels used for dispatch selection.
    - Additional properties:
      - Type: `string | boolean | number`
      - One of:
        - Variant 1:
          - Type: `string`
        - Variant 2:
          - Type: `boolean`
        - Variant 3:
          - Type: `number`
  - `runIds` (`array<integer>`) — Run IDs currently in flight on the executor; their leases are renewed on register.
    - Description: Run IDs currently in flight on the executor; their leases are renewed on register.
    - Items:
      - Type: `integer`

## Success responses

### 200

Registered.

**Content type:** `application/json`

- Type: `object`
- Properties:
  - `registered` (`boolean`)

## Error responses

### 400

Validation error

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "VALIDATION_ERROR",
  "message": "Invalid input"
}
```

## Examples

### cURL

```bash
curl --request POST \
  --url 'https://your-envoy.example.com/api/executors/register' \
  --header 'Authorization: Bearer $EXECUTOR_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "url": "string",
  "maxConcurrent": 0
}'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/executors/register', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_EXECUTOR_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "url": "string",
    "maxConcurrent": 0
  }),
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
