# Ask API

> Ask a question and get an answer written from the Stacksync docs, over HTTP

Source: https://docs.stacksync.com/docs-for-ai/ask-api

The Ask API answers a question in plain language using the Stacksync documentation. It's the same assistant as **Ask AI** on this site: it searches the docs, answers only from what it finds, and links to the pages it used. Use it from scripts, support bots or agents that don't support [MCP](/docs-for-ai/mcp-server).

### Request

Send a `POST` request with the question as JSON (3 to 2,000 characters). No API key is needed.

```bash
curl -X POST https://docs.stacksync.com/api/ask \
  -H "Content-Type: application/json" \
  -d '{"question": "How do I connect Salesforce?"}'
```

### Response

The answer is returned as Markdown (`text/markdown`), with absolute links to the docs pages it's based on:

```markdown
To connect Salesforce, you authorize it from the Create Sync page. This follows [Authorize Salesforce](https://docs.stacksync.com/connectors/salesforce/authorize-salesforce).

1. In Stacksync, open the **Create Sync** page and select **Salesforce**.
2. ...
```

To get JSON instead, send `Accept: application/json`:

```bash
curl -X POST https://docs.stacksync.com/api/ask \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"question": "How do I connect Salesforce?"}'
```

```json
{
  "question": "How do I connect Salesforce?",
  "answer": "To connect Salesforce, you authorize it from the Create Sync page..."
}
```

### Errors

| Status | Meaning                                                                                                                                                                                |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | The body isn't `{"question": "..."}`, or the question is shorter than 3 or longer than 2,000 characters                                                                                |
| `503`  | The assistant is temporarily unavailable. Use the [MCP server](/docs-for-ai/mcp-server)'s `search` and `get_page` tools, or the [Markdown pages](/docs-for-ai#markdown-pages), instead |

<Callout type="info">
  Answers are generated by AI from the documentation and can be incomplete. For anything critical, check the linked pages, or contact [Stacksync support](https://www.stacksync.com/contact).
</Callout>