> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Generate a tool

POST https://api.getpostman.com/postbot/generations/tool
Content-Type: application/json

**This endpoint is deprecated**

Generates code for an AI agent tool using a collection and request from the Public API Network. For more information, see [**Tool Generation Demo**](http://postman.com/explore/toolgen) in Postman's Public API Network.

### Important

- This endpoint has a rate limit of **300 calls every 3 hours**. This does not accrue Postbot usage.
- This endpoint only supports public Postman Collections and requests.


Reference: https://learning.postman.com/api-docs/api-reference/postbot/generate-tool

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /postbot/generations/tool:
    post:
      operationId: generateTool
      summary: Generate a tool
      description: >
        **This endpoint is deprecated**


        Generates code for an AI agent tool using a collection and request from
        the Public API Network. For more information, see [**Tool Generation
        Demo**](http://postman.com/explore/toolgen) in Postman's Public API
        Network.


        ### Important


        - This endpoint has a rate limit of **300 calls every 3 hours**. This
        does not accrue Postbot usage.

        - This endpoint only supports public Postman Collections and requests.
      tags:
        - postbot
      parameters:
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/generateToolResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/postbot400Error'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateToolRequestInternalServerError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/generateTool'
servers:
  - url: https://api.getpostman.com
    description: https://api.getpostman.com
  - url: https://api.eu.postman.com
    description: https://api.eu.postman.com
components:
  schemas:
    GenerateToolConfigLanguage:
      type: string
      enum:
        - javascript
        - typescript
        - python
      description: The programming language to use.
      title: GenerateToolConfigLanguage
    GenerateToolConfigAgentFramework:
      type: string
      enum:
        - openai
        - mistral
        - gemini
        - anthropic
        - langchain
        - autogen
      description: >-
        The AI agent framework to use. Note that the `autogen` framework only
        supports the `python` language.
      title: GenerateToolConfigAgentFramework
    GenerateToolConfig:
      type: object
      properties:
        language:
          $ref: '#/components/schemas/GenerateToolConfigLanguage'
          description: The programming language to use.
        agentFramework:
          $ref: '#/components/schemas/GenerateToolConfigAgentFramework'
          description: >-
            The AI agent framework to use. Note that the `autogen` framework
            only supports the `python` language.
      required:
        - language
        - agentFramework
      description: Information about the request.
      title: GenerateToolConfig
    generateTool:
      type: object
      properties:
        requestId:
          type: string
          description: The public collection's request ID.
        collectionId:
          type: string
          format: uid
          description: The Public API Network collection's ID.
        config:
          $ref: '#/components/schemas/GenerateToolConfig'
          description: Information about the request.
      required:
        - requestId
        - collectionId
        - config
      title: generateTool
    GenerateToolResponseData:
      type: object
      properties:
        text:
          type: string
          description: The generated tool code.
      description: The generated response data.
      title: GenerateToolResponseData
    generateToolResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/GenerateToolResponseData'
          description: The generated response data.
      title: generateToolResponse
    postbot400Error:
      type: object
      properties:
        detail:
          type: string
          description: Details about the occurrence of the error.
        status:
          type: number
          format: double
          description: The error's HTTP status code.
        title:
          type: string
          description: A short summary of the error.
        type:
          type: string
          format: uri
          description: The error type.
      title: postbot400Error
    CommonErrorTypeTitleDetailStatusType:
      oneOf:
        - type: string
          format: uri-reference
        - type: string
      title: CommonErrorTypeTitleDetailStatusType
    commonErrorTypeTitleDetailStatus:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/CommonErrorTypeTitleDetailStatusType'
        title:
          type: string
          description: A short summary of the problem.
        detail:
          type: string
          description: Information about the error.
        status:
          type: integer
          description: The error's HTTP status code.
      title: commonErrorTypeTitleDetailStatus
    CommonErrorTypeTitleDetailDetail:
      oneOf:
        - type: string
        - type: object
          additionalProperties:
            description: Any type
      description: Information about the error.
      title: CommonErrorTypeTitleDetailDetail
    commonErrorTypeTitleDetail:
      type: object
      properties:
        type:
          type: string
          description: The type of error.
        title:
          type: string
          description: A short summary of the problem.
        detail:
          $ref: '#/components/schemas/CommonErrorTypeTitleDetailDetail'
          description: Information about the error.
      title: commonErrorTypeTitleDetail
    CommonErrorNameMessageError:
      type: object
      properties:
        name:
          type: string
          description: The error name.
        message:
          type: string
          description: The error message.
      description: Information about the error.
      title: CommonErrorNameMessageError
    commonErrorNameMessage:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/CommonErrorNameMessageError'
          description: Information about the error.
      title: commonErrorNameMessage
    GenerateToolRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: GenerateToolRequestInternalServerError
  securitySchemes:
    PostmanApiKey:
      type: apiKey
      in: header
      name: x-api-key
    scimApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        A valid [SCIM API
        key](https://learning.postman.com/docs/administration/scim-provisioning/scim-provisioning-overview/#generating-scim-api-key)
        for calls to SCIM endpoints.
    basicAuth:
      type: http
      scheme: basic

```

## Examples

### Successful Response



**Request**

```json
undefined
```

**Response**

```json
{
  "data": {
    "text": "/**\n * Function to query a Notion database.\n *\n * @param {Object} args - Arguments for the query.\n * @param {string} args.databaseId - The ID of the Notion database to query.\n * @param {Object} [args.filter] - The filter conditions for the query.\n * @param {Array} [args.sorts] - The sort conditions for the query.\n * @returns {Promise<Object>} - The result of the database query.\n */\nconst executeFunction = async ({ databaseId, filter, sorts }) => {\n    // NOTE before using the tool: verify this section is correct\n    const baseUrl = `https://api.notion.com/v1/databases/${databaseId}/query`;\n    \n    // NOTE! Replace this with your actual API token\n    const token = process.env.NOTION_API_TOKEN;\n    const notionVersion = process.env.NOTION_VERSION || '2022-06-28'; // Default version, update as needed\n\n    // Set up headers for the request\n    const headers = {\n        'Authorization': `Bearer ${token}`,\n        'Content-Type': 'application/json',\n        'Notion-Version': notionVersion,\n    };\n\n    const body = JSON.stringify({\n        filter,\n        sorts,\n    });\n\n    // Perform the fetch request\n    const response = await fetch(baseUrl, {\n        method: 'POST',\n        headers,\n        body\n    });\n\n    // Check if the response was successful\n    if (!response.ok) {\n        const errorData = await response.json();\n        throw new Error(errorData);\n    }\n\n    // Parse and return the response data\n    const data = await response.json();\n    return data;\n};\n\n/**\n * Tool configuration for querying a Notion database.\n * @type {Object}\n */\nconst apiTool = {\n    type: 'function',\n    function: {\n        name: 'query_notion_database',\n        function: executeFunction,\n        description: 'Query a Notion database using specific filter and sort parameters.',\n        parse: JSON.parse,\n        parameters: {\n            type: 'object',\n            properties: {\n                databaseId: {\n                    type: 'string',\n                    description: 'The ID of the Notion database to query.',\n                },\n                filter: {\n                    type: 'object',\n                    description: 'The filter conditions for the query.',\n                },\n                sorts: {\n                    type: 'array',\n                    description: 'The sort conditions for the query.',\n                    items: {\n                        type: 'object',\n                        properties: {\n                            property: {\n                                type: 'string',\n                                description: 'The database property to sort by.',\n                            },\n                            direction: {\n                                type: 'string',\n                                description: 'The direction of sorting, either \"ascending\" or \"descending\".',\n                                enum: ['ascending', 'descending'],\n                            },\n                        },\n                    },\n                },\n            },\n            required: ['databaseId'],\n            additionalProperties: false,\n        },\n    },\n};\n\nexport default apiTool;"
  }
}
```

**SDK Code**

```python Successful Response
import requests

url = "https://api.getpostman.com/postbot/generations/tool"

headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Successful Response
const url = 'https://api.getpostman.com/postbot/generations/tool';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go Successful Response
package main

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

func main() {

	url := "https://api.getpostman.com/postbot/generations/tool"

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

	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 Successful Response
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/postbot/generations/tool")

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'

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

```java Successful Response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/postbot/generations/tool")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Successful Response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/postbot/generations/tool', [
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Successful Response
using RestSharp;

var client = new RestClient("https://api.getpostman.com/postbot/generations/tool");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Successful Response
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/postbot/generations/tool")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Generate Tool



**Request**

```json
{
  "requestId": "c82dd02c-4870-4907-8fcb-593a876cf05b",
  "collectionId": "12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2",
  "config": {
    "language": "javascript",
    "agentFramework": "openai"
  }
}
```

**Response**

```json
{
  "data": {
    "text": "/**\n * Function to query a Notion database.\n *\n * @param {Object} args - Arguments for the query.\n * @param {string} args.databaseId - The ID of the Notion database to query.\n * @param {Object} [args.filter] - The filter conditions for the query.\n * @param {Array} [args.sorts] - The sort conditions for the query.\n * @returns {Promise<Object>} - The result of the database query.\n */\nconst executeFunction = async ({ databaseId, filter, sorts }) => {\n    // NOTE before using the tool: verify this section is correct\n    const baseUrl = `https://api.notion.com/v1/databases/${databaseId}/query`;\n    \n    // NOTE! Replace this with your actual API token\n    const token = process.env.NOTION_API_TOKEN;\n    const notionVersion = process.env.NOTION_VERSION || '2022-06-28'; // Default version, update as needed\n\n    // Set up headers for the request\n    const headers = {\n        'Authorization': `Bearer ${token}`,\n        'Content-Type': 'application/json',\n        'Notion-Version': notionVersion,\n    };\n\n    const body = JSON.stringify({\n        filter,\n        sorts,\n    });\n\n    // Perform the fetch request\n    const response = await fetch(baseUrl, {\n        method: 'POST',\n        headers,\n        body\n    });\n\n    // Check if the response was successful\n    if (!response.ok) {\n        const errorData = await response.json();\n        throw new Error(errorData);\n    }\n\n    // Parse and return the response data\n    const data = await response.json();\n    return data;\n};\n\n/**\n * Tool configuration for querying a Notion database.\n * @type {Object}\n */\nconst apiTool = {\n    type: 'function',\n    function: {\n        name: 'query_notion_database',\n        function: executeFunction,\n        description: 'Query a Notion database using specific filter and sort parameters.',\n        parse: JSON.parse,\n        parameters: {\n            type: 'object',\n            properties: {\n                databaseId: {\n                    type: 'string',\n                    description: 'The ID of the Notion database to query.',\n                },\n                filter: {\n                    type: 'object',\n                    description: 'The filter conditions for the query.',\n                },\n                sorts: {\n                    type: 'array',\n                    description: 'The sort conditions for the query.',\n                    items: {\n                        type: 'object',\n                        properties: {\n                            property: {\n                                type: 'string',\n                                description: 'The database property to sort by.',\n                            },\n                            direction: {\n                                type: 'string',\n                                description: 'The direction of sorting, either \"ascending\" or \"descending\".',\n                                enum: ['ascending', 'descending'],\n                            },\n                        },\n                    },\n                },\n            },\n            required: ['databaseId'],\n            additionalProperties: false,\n        },\n    },\n};\n\nexport default apiTool;"
  }
}
```

**SDK Code**

```python Generate Tool
import requests

url = "https://api.getpostman.com/postbot/generations/tool"

payload = {
    "requestId": "c82dd02c-4870-4907-8fcb-593a876cf05b",
    "collectionId": "12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2",
    "config": {
        "language": "javascript",
        "agentFramework": "openai"
    }
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Generate Tool
const url = 'https://api.getpostman.com/postbot/generations/tool';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"requestId":"c82dd02c-4870-4907-8fcb-593a876cf05b","collectionId":"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2","config":{"language":"javascript","agentFramework":"openai"}}'
};

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

```go Generate Tool
package main

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

func main() {

	url := "https://api.getpostman.com/postbot/generations/tool"

	payload := strings.NewReader("{\n  \"requestId\": \"c82dd02c-4870-4907-8fcb-593a876cf05b\",\n  \"collectionId\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n  \"config\": {\n    \"language\": \"javascript\",\n    \"agentFramework\": \"openai\"\n  }\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 Generate Tool
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/postbot/generations/tool")

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  \"requestId\": \"c82dd02c-4870-4907-8fcb-593a876cf05b\",\n  \"collectionId\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n  \"config\": {\n    \"language\": \"javascript\",\n    \"agentFramework\": \"openai\"\n  }\n}"

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

```java Generate Tool
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/postbot/generations/tool")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"requestId\": \"c82dd02c-4870-4907-8fcb-593a876cf05b\",\n  \"collectionId\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n  \"config\": {\n    \"language\": \"javascript\",\n    \"agentFramework\": \"openai\"\n  }\n}")
  .asString();
```

```php Generate Tool
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/postbot/generations/tool', [
  'body' => '{
  "requestId": "c82dd02c-4870-4907-8fcb-593a876cf05b",
  "collectionId": "12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2",
  "config": {
    "language": "javascript",
    "agentFramework": "openai"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Generate Tool
using RestSharp;

var client = new RestClient("https://api.getpostman.com/postbot/generations/tool");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"requestId\": \"c82dd02c-4870-4907-8fcb-593a876cf05b\",\n  \"collectionId\": \"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2\",\n  \"config\": {\n    \"language\": \"javascript\",\n    \"agentFramework\": \"openai\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Generate Tool
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "requestId": "c82dd02c-4870-4907-8fcb-593a876cf05b",
  "collectionId": "12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2",
  "config": [
    "language": "javascript",
    "agentFramework": "openai"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/postbot/generations/tool")! 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()
```