> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Submit a Context Graph ask

POST https://api.postman.com/context-graph/asks
Content-Type: application/json

Submits a natural-language question about your team's Context Graph.

Asks are asynchronous. On success, this returns an HTTP `202 Accepted` response with the ask's `askId`. Send a request to the GET `/context-graph/asks/{askId}` endpoint to poll the ask for its status and, once it completes, its result.

**Note:**

Postman derives the team from your API key.

Reference: https://learning.postman.com/api-docs/api-reference/context-graph/submit-context-graph-ask

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Servers

- `https://api.postman.com` (https://api.postman.com, default)
- `https://api.eu.postman.com` (https://api.eu.postman.com)

## Request

### Body (application/json)

This endpoint expects an object.

- `query` (string, required) — The natural-language question to answer against the graph.
- `includeAnswer` (boolean, optional, default: true) — Whether to include the prose answer in the result. If `false`, the result's `answer` property is `null` and the result's other properties are unaffected.
- `maxSteps` (integer, optional, default: 10) — The maximum number of tool calls the ask can make. Must be between `1` and `15`.

## Response

### 202

Accepted

- `askId` (string, required) — The created ask's ID. Use this value to poll the ask.
- `status` (enum, required) — The ask's lifecycle state.
  - Allowed values: `pending`, `running`, `completed`, `failed`

## Errors

### 400 Bad Request Error

Bad Request

- `type` (string, optional) — The [URI reference](https://www.rfc-editor.org/rfc/rfc3986) that identifies the type of problem.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — An explanation about the problem.
- `status` (integer, optional) — The HTTP status code generated by the origin server.
- `instance` (string, optional) — The URI reference that identifies the specific occurrence of the problem.

### 401 Unauthorized Error

Unauthorized

- `object or object`
  - Error (Type, Title, Detail, Status)
    - `type` (string or string, optional) — The type of error.
    - `title` (string, optional) — A short summary of the problem.
    - `detail` (string, optional) — Information about the error.
    - `status` (integer, optional) — The error's HTTP status code.
  - Error (Name, Message)
    - `error` (object, optional) — Information about the error.
      - `name` (string, optional) — The error name.
      - `message` (string, optional) — The error message.

### 403 Forbidden Error

Forbidden

- `type` (string, optional) — The [URI reference](https://www.rfc-editor.org/rfc/rfc3986) that identifies the type of problem.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — An explanation about the problem.
- `status` (integer, optional) — The HTTP status code generated by the origin server.
- `instance` (string, optional) — The URI reference that identifies the specific occurrence of the problem.

### 429 Too Many Requests Error

Too Many Requests

- `type` (string, optional) — The [URI reference](https://www.rfc-editor.org/rfc/rfc3986) that identifies the type of problem.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — An explanation about the problem.
- `status` (integer, optional) — The HTTP status code generated by the origin server.
- `instance` (string, optional) — The URI reference that identifies the specific occurrence of the problem.

### 500 Internal Server Error

Internal Server Error

- `object or object or object`
  - Error (Type, Title, Detail)
    - `type` (string, optional) — The type of error.
    - `title` (string, optional) — A short summary of the problem.
    - `detail` (string or map from string to any, optional) — Information about the error.
  - Error (Type, Title, Detail, Status)
    - `type` (string or string, optional) — The type of error.
    - `title` (string, optional) — A short summary of the problem.
    - `detail` (string, optional) — Information about the error.
    - `status` (integer, optional) — The error's HTTP status code.
  - Error (Name, Message)
    - `error` (object, optional) — Information about the error.
      - `name` (string, optional) — The error name.
      - `message` (string, optional) — The error message.

## Examples

### Submit an Ask

**Request**

```json
{
  "query": "What endpoints does authentication-service expose?",
  "includeAnswer": true,
  "maxSteps": 8
}
```

**Response**

```json
{
  "askId": "01a03dd2-0d99-766e-b3df-e36dcaaee706",
  "status": "pending"
}
```

**SDK Code**

```python Submit an Ask
import requests

url = "https://api.postman.com/context-graph/asks"

payload = {
    "query": "What endpoints does authentication-service expose?",
    "includeAnswer": True,
    "maxSteps": 8
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Submit an Ask
const url = 'https://api.postman.com/context-graph/asks';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"query":"What endpoints does authentication-service expose?","includeAnswer":true,"maxSteps":8}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Submit an Ask
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.postman.com/context-graph/asks"

	payload := strings.NewReader("{\n  \"query\": \"What endpoints does authentication-service expose?\",\n  \"includeAnswer\": true,\n  \"maxSteps\": 8\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Submit an Ask
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/context-graph/asks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"query\": \"What endpoints does authentication-service expose?\",\n  \"includeAnswer\": true,\n  \"maxSteps\": 8\n}"

response = http.request(request)
puts response.read_body
```

```java Submit an Ask
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.postman.com/context-graph/asks")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"query\": \"What endpoints does authentication-service expose?\",\n  \"includeAnswer\": true,\n  \"maxSteps\": 8\n}")
  .asString();
```

```php Submit an Ask
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/context-graph/asks', [
  'body' => '{
  "query": "What endpoints does authentication-service expose?",
  "includeAnswer": true,
  "maxSteps": 8
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Submit an Ask
using RestSharp;

var client = new RestClient("https://api.postman.com/context-graph/asks");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"query\": \"What endpoints does authentication-service expose?\",\n  \"includeAnswer\": true,\n  \"maxSteps\": 8\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Submit an Ask
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "query": "What endpoints does authentication-service expose?",
  "includeAnswer": true,
  "maxSteps": 8
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/context-graph/asks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Structured Data Only

**Request**

```json
{
  "query": "Which APIs depend on the payments service?",
  "includeAnswer": false
}
```

**Response**

```json
{
  "askId": "01a03dd2-0d99-766e-b3df-e36dcaaee706",
  "status": "pending"
}
```

**SDK Code**

```python Structured Data Only
import requests

url = "https://api.postman.com/context-graph/asks"

payload = {
    "query": "Which APIs depend on the payments service?",
    "includeAnswer": False
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Structured Data Only
const url = 'https://api.postman.com/context-graph/asks';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"query":"Which APIs depend on the payments service?","includeAnswer":false}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Structured Data Only
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.postman.com/context-graph/asks"

	payload := strings.NewReader("{\n  \"query\": \"Which APIs depend on the payments service?\",\n  \"includeAnswer\": false\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Structured Data Only
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/context-graph/asks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"query\": \"Which APIs depend on the payments service?\",\n  \"includeAnswer\": false\n}"

response = http.request(request)
puts response.read_body
```

```java Structured Data Only
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.postman.com/context-graph/asks")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"query\": \"Which APIs depend on the payments service?\",\n  \"includeAnswer\": false\n}")
  .asString();
```

```php Structured Data Only
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.postman.com/context-graph/asks', [
  'body' => '{
  "query": "Which APIs depend on the payments service?",
  "includeAnswer": false
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Structured Data Only
using RestSharp;

var client = new RestClient("https://api.postman.com/context-graph/asks");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"query\": \"Which APIs depend on the payments service?\",\n  \"includeAnswer\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Structured Data Only
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "query": "Which APIs depend on the payments service?",
  "includeAnswer": false
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/context-graph/asks")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```