---
title: "Ask LeadGPT for agent action recommendations"
description: "Returns non-mutating LeadGPT action cards for the authenticated workspace. The route derives workspace access from apiKeyAuth and only uses the client workspace id for auth scoping."
---

> Documentation Index
> Fetch the complete documentation index at: https://developer.channelautomations.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Channel Automation API › Customer Hub

`POST /api/customer-hub/leadgpt/ask`

Returns non-mutating LeadGPT action cards for the authenticated workspace. The route derives workspace access from apiKeyAuth and only uses the client workspace id for auth scoping.

## Authentication

Requires one of the following:

- `BearerAuth`, http, header `Authorization`, format `JWT`
- `ApiKeyAuth`, apiKey, in header, header `X-API-Key`, format `API_KEY`

## Request body

_Required._

- `workspace_id` (`post/api/customer-hub/leadgpt/ask.workspace_id`; string, required) — Workspace id used by apiKeyAuth to validate membership. Business logic uses req.user.workspace_id after authentication.
- `prompt` (`post/api/customer-hub/leadgpt/ask.prompt`; string, optional) — Natural language LeadGPT prompt. Empty prompts default to "What should I do next?"
- `selectedContactId` (`post/api/customer-hub/leadgpt/ask.selectedContactId`; string, optional) — Optional contact id to summarize or draft against.
  - format `uuid`

## Example request

```json
{
  "workspace_id": "string",
  "prompt": "string",
  "selectedContactId": "1b5e8964-45aa-454a-bfa3-92a6f9bcf78f"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.channelautomation.com/api/customer-hub/leadgpt/ask \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "workspace_id": "string",
  "prompt": "string",
  "selectedContactId": "1b5e8964-45aa-454a-bfa3-92a6f9bcf78f"
}
'
```

### TypeScript

```typescript
const url = 'https://api.channelautomation.com/api/customer-hub/leadgpt/ask';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    workspace_id: 'string',
    prompt: 'string',
    selectedContactId: '1b5e8964-45aa-454a-bfa3-92a6f9bcf78f'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.channelautomation.com/api/customer-hub/leadgpt/ask"

payload = {
    "workspace_id": "string",
    "prompt": "string",
    "selectedContactId": "1b5e8964-45aa-454a-bfa3-92a6f9bcf78f"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

LeadGPT answer and ranked non-mutating action cards

### 400

Missing workspace access or invalid request

### 401

Authentication required

#### Example

```json
{
  "error": "Authentication required",
  "success": false
}
```

- `error` (`post/api/customer-hub/leadgpt/ask.response.401.error`; string, optional)
  - example `"Authentication required"`
- `success` (`post/api/customer-hub/leadgpt/ask.response.401.success`; boolean, optional)
  - example `false`

### 404

Selected contact is not available in the authenticated workspace

### 500

Internal server error

#### Example

```json
{
  "error": "Internal server error",
  "details": "string",
  "success": false
}
```

- `error` (`post/api/customer-hub/leadgpt/ask.response.500.error`; string, optional)
  - example `"Internal server error"`
- `details` (`post/api/customer-hub/leadgpt/ask.response.500.details`; string, optional)
- `success` (`post/api/customer-hub/leadgpt/ask.response.500.success`; boolean, optional)
  - example `false`


Source: https://developer.channelautomations.com/api/post-api-customer-hub-leadgpt-ask/index.md
