# Create ask

URL: https://docs.hanzo.ai/docs/openapi/code/post-code-ask

> Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL.

`POST /v1/code/ask`

> [Code →](https://docs.hanzo.ai/docs/openapi/code) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/code/ask`     |
| **Method**    | `POST`                                 |
| **Operation** | `post_code_ask`                        |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Answers a question about the caller org's code with a CITED answer,
taking the question from the request BODY, for a question too long or too
awkward to put in a URL. `query` and `repo` in the body take precedence over
`?q=` and `?repo=`; either source works alone.

## Request

2 fields, body `application/json` (required).

| Field   | In   | Type   | Required | Description                                      |
| ------- | ---- | ------ | -------- | ------------------------------------------------ |
| `query` | body | string | —        | Query is the question, from the BODY.            |
| `repo`  | body | string | —        | Repo is the repository narrowing, from the BODY. |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | code.AskAnswer  | ok      |
| `default` | problem-details | refused |

`200` body — 9 fields.

| Field                 | In   | Type             | Always | Description                                                                                                                                                                    |
| --------------------- | ---- | ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `answer`              | body | string           | —      | Answer is the synthesized prose.                                                                                                                                               |
| `citations`           | body | code.Citation\[] | —      | Citations are the exact regions the answer was grounded on, and they are the point: an answer is checkable only because every claim in it can be read back at a file and line. |
| `citations[].endLine` | body | integer (int64)  | —      | EndLine is its last line, inclusive.                                                                                                                                           |
| `citations[].file`    | body | string           | —      | File is the path inside the repo, relative to its root.                                                                                                                        |
| `citations[].line`    | body | integer (int64)  | —      | Line is the first line of the cited region, 1-based.                                                                                                                           |
| `citations[].repo`    | body | string           | —      | Repo is the repository the cited code lives in ("owner/name"), absent when the ask was already scoped to one.                                                                  |
| `citations[].symbol`  | body | string           | —      | Symbol is the declaration the region belongs to, when it belongs to one.                                                                                                       |
| `degraded`            | body | boolean          | —      | Degraded is true when retrieval worked but no synthesizer was reachable.                                                                                                       |
| `question`            | body | string           | —      | Question is the ask, echoed back.                                                                                                                                              |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo code ask create
```

**SDK**

**.ts**

```ts
import { Configuration, CodeApi } from 'hanzoai';

const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postCodeAsk({ query: "<query>", repo: "<repo>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CodeApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CodeApi(client).post_code_ask(query="<query>", repo="<repo>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.CodeAPI.PostCodeAsk(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, code_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = code_api::post_code_ask(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new CodeApi(client).postCodeAsk();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/code/ask \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "query": "<query>",
       "repo": "<repo>"
     }'
```

**MCP**

MCP reaches **code** through the `code` tool, which names its 7 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "get_code_ask"
         }
       }
     }'
```

---

[Code API](https://docs.hanzo.ai/docs/openapi/code) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
