# CRM · Pipelines

Part of AppEngine API Documentation. Full index: https://appengine.appmint.io/documentation.md
## GET /crm/leads/pipelines

**List lead pipelines**

`operationId: LeadsController_getPipelines`

All lead pipelines in the org, with their stages.

#### Signature

```http
GET /crm/leads/pipelines () -> The org's pipelines
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `500` | OPERATION_FAILED | Failed to retrieve pipelines | An unexpected failure in the leads service. | Retry with backoff. The message is fixed text and does not indicate what went wrong. |

Plus the standard platform errors: `401`, `403`, `429`.

#### See also

- `GET /crm/leads/pipelines/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |

### Responses

| Status | Meaning |
| --- | --- |
| `200` | The org's pipelines |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | Failed to retrieve pipelines — An unexpected failure in the leads service. |

## POST /crm/leads/pipelines

**Create a lead pipeline**

`operationId: LeadsController_createPipeline`

Creates a pipeline — the ordered stages a lead moves through. Stages can be added, reordered and removed afterwards.

#### Signature

```http
POST /crm/leads/pipelines (body) -> The created pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `500` | OPERATION_FAILED | Failed to create pipeline | An unexpected failure in the leads service. | Retry with backoff. The message is fixed text and does not indicate what went wrong. |

Plus the standard platform errors: `401`, `403`, `429`.

#### See also

- `POST /crm/leads/pipelines/stages/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |

### Request body

The pipeline to create.

```json
{
  "name": "Inbound sales",
  "stages": [
    {
      "name": "New"
    },
    {
      "name": "Contacted"
    },
    {
      "name": "Demo booked"
    }
  ]
}
```

### Responses

| Status | Meaning |
| --- | --- |
| `201` | The created pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | Failed to create pipeline — An unexpected failure in the leads service. |

## GET /crm/leads/pipelines/{id}

**Get a lead pipeline**

`operationId: LeadsController_getPipeline`

Fetches one pipeline with its ordered stages.

#### Signature

```http
GET /crm/leads/pipelines/{id} (id: string) -> The pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |
| `500` | OPERATION_FAILED | Failed to retrieve pipeline | An unexpected failure in the leads service. | Retry with backoff. The message is fixed text and does not indicate what went wrong. |

Plus the standard platform errors: `401`, `403`, `429`.

#### See also

- `PUT /crm/leads/pipelines/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |

### Responses

| Status | Meaning |
| --- | --- |
| `200` | The pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | Failed to retrieve pipeline — An unexpected failure in the leads service. |

## PUT /crm/leads/pipelines/{id}

**Update a lead pipeline**

`operationId: LeadsController_updatePipeline`

Updates a pipeline's own fields. Use the stage endpoints to change its stages.

#### Signature

```http
PUT /crm/leads/pipelines/{id} (id: string, body) -> The updated pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |
| `500` | OPERATION_FAILED | Failed to update pipeline | An unexpected failure in the leads service. | Retry with backoff. The message is fixed text and does not indicate what went wrong. |

Plus the standard platform errors: `401`, `403`, `429`.

#### See also

- `PUT /crm/leads/pipelines/stages/{id}/{stageId}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |

### Request body

Fields to change.

```json
{
  "name": "Inbound sales (EMEA)"
}
```

### Responses

| Status | Meaning |
| --- | --- |
| `200` | The updated pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | Failed to update pipeline — An unexpected failure in the leads service. |

## DELETE /crm/leads/pipelines/{id}

**Delete a lead pipeline**

`operationId: LeadsController_deletePipeline`

Deletes a pipeline. **A pipeline still holding leads cannot be deleted** — move or delete those leads first, so none are left pointing at a stage that no longer exists.

#### Signature

```http
DELETE /crm/leads/pipelines/{id} (id: string) -> Deletion result
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |
| `400` | PIPELINE_IN_USE | Cannot delete pipeline with existing leads | Leads are still assigned to this pipeline. | Move the leads to another pipeline first, or delete them. |

Plus the standard platform errors: `401`, `403`, `429`, `500`.

#### See also

- `GET /crm/leads/detail`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |

### Responses

| Status | Meaning |
| --- | --- |
| `200` | Deletion result |
| `400` | Cannot delete pipeline with existing leads — Leads are still assigned to this pipeline. |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | An unexpected error occurred. Our team has been notified. — An unhandled server-side failure. |

## POST /crm/leads/pipelines/{id}/route-unassigned

**Route unassigned leads in a pipeline**

`operationId: LeadsController_routeUnassignedInPipeline`

Distributes the pipeline's unassigned leads across owners according to its routing rules — the bulk alternative to assigning them one at a time.

#### Signature

```http
POST /crm/leads/pipelines/{id}/route-unassigned (id: string) -> The routing result
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |

Plus the standard platform errors: `401`, `403`, `429`, `500`.

#### See also

- `POST /crm/leads/assign/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |

### Responses

| Status | Meaning |
| --- | --- |
| `201` | The routing result |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | An unexpected error occurred. Our team has been notified. — An unhandled server-side failure. |

## POST /crm/leads/pipelines/stages/{id}

**Add a stage to a pipeline**

`operationId: LeadsController_addPipelineStage`

Appends a stage to a pipeline. Use the reorder endpoint to place it somewhere other than the end.

#### Signature

```http
POST /crm/leads/pipelines/stages/{id} (id: string, body) -> The updated pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |

Plus the standard platform errors: `401`, `403`, `429`, `500`.

#### See also

- `PUT /crm/leads/pipelines/stages/reorder/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |

### Request body

The stage to add.

```json
{
  "name": "Proposal sent"
}
```

### Responses

| Status | Meaning |
| --- | --- |
| `201` | The updated pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | An unexpected error occurred. Our team has been notified. — An unhandled server-side failure. |

## PUT /crm/leads/pipelines/stages/{id}/{stageId}

**Update a pipeline stage**

`operationId: LeadsController_updatePipelineStage`

Updates one stage within a pipeline.

#### Signature

```http
PUT /crm/leads/pipelines/stages/{id}/{stageId} (id: string, stageId: string, body) -> The updated pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |

Plus the standard platform errors: `401`, `403`, `429`, `500`.

#### See also

- `DELETE /crm/leads/pipelines/stages/{id}/{stageId}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |
| `stageId` | path | string | yes | Stage id within the pipeline. |

### Request body

Fields to change.

```json
{
  "name": "Proposal sent (v2)"
}
```

### Responses

| Status | Meaning |
| --- | --- |
| `200` | The updated pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | An unexpected error occurred. Our team has been notified. — An unhandled server-side failure. |

## DELETE /crm/leads/pipelines/stages/{id}/{stageId}

**Delete a pipeline stage**

`operationId: LeadsController_deletePipelineStage`

Removes a stage from a pipeline. Move any leads sitting in it first — nothing here relocates them, and a lead pointing at a deleted stage falls out of the board.

#### Signature

```http
DELETE /crm/leads/pipelines/stages/{id}/{stageId} (id: string, stageId: string) -> The updated pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Notes

- Leads in the deleted stage are not moved — check the stage is empty first.

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |

Plus the standard platform errors: `401`, `403`, `429`, `500`.

#### See also

- `PUT /crm/leads/pipelines/stages/reorder/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |
| `stageId` | path | string | yes | Stage id within the pipeline. |

### Responses

| Status | Meaning |
| --- | --- |
| `200` | The updated pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | An unexpected error occurred. Our team has been notified. — An unhandled server-side failure. |

## PUT /crm/leads/pipelines/stages/reorder/{id}

**Reorder pipeline stages**

`operationId: LeadsController_reorderPipelineStages`

Changes the order of a pipeline's stages. Send the stage ids in the order you want them.

#### Signature

```http
PUT /crm/leads/pipelines/stages/reorder/{id} (id: string, body) -> The reordered pipeline
```

#### Access

Requires a bearer JWT (`Authorization: Bearer <token>`).

#### Notes

- Send every stage — an omitted one may lose its position.

#### Errors

| Status | Code | Message | When | What to do |
| --- | --- | --- | --- | --- |
| `404` | PIPELINE_NOT_FOUND | Pipeline not found | No pipeline in the org has that id. | List pipelines with `GET /crm/leads/pipelines`. |

Plus the standard platform errors: `401`, `403`, `429`, `500`.

#### See also

- `POST /crm/leads/pipelines/stages/{id}`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `orgid` | header | string | yes | Organization (tenant) identifier. Every request is scoped to this org; data from other orgs is never visible. Issued with your API credentials. |
| `id` | path | string | yes | Pipeline id. |

### Request body

The stages in their new order.

```json
{
  "stageIds": [
    "STG-1",
    "STG-3",
    "STG-2"
  ]
}
```

### Responses

| Status | Meaning |
| --- | --- |
| `200` | The reordered pipeline |
| `401` | Authentication failed: Invalid or expired token — The `Authorization` header is missing, malformed, or the JWT has expired. |
| `403` | You do not have permission to perform this action — The caller is authenticated but lacks the role required by the endpoint, or is acting on another org. |
| `404` | Pipeline not found — No pipeline in the org has that id. |
| `429` | Too Many Requests — More than 100,000 requests from one IP within 5 minutes (configurable per deployment). CORS preflights and requests from inside the platform cluster are not counted. The limiter answers before the error filter, so the body is `{ statusCode, error, message }` with no `path`, `method` or `timeStamp`; the `RateLimit-*` response headers say when the window resets. |
| `500` | An unexpected error occurred. Our team has been notified. — An unhandled server-side failure. |

