Skip to main content
POST
/
tool
Create Tool
curl --request POST \
  --url https://api.cozmox.ai/tool \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "type": "apiRequest",
  "method": "POST",
  "url": "<string>",
  "messages": [
    {
      "type": "request-start",
      "contents": [
        {
          "type": "text",
          "text": "<string>",
          "language": "aa"
        }
      ],
      "blocking": false,
      "content": "<string>",
      "conditions": [
        {
          "operator": "eq",
          "param": "<string>",
          "value": "<string>"
        }
      ]
    }
  ],
  "timeoutSeconds": 20,
  "name": "<string>",
  "description": "<string>",
  "body": {
    "type": "string",
    "items": {},
    "properties": {},
    "description": "<string>",
    "pattern": "<string>",
    "format": "date-time",
    "required": [
      "<string>"
    ],
    "enum": [
      "<string>"
    ],
    "title": "<string>"
  },
  "headers": {
    "type": "string",
    "items": {},
    "properties": {},
    "description": "<string>",
    "pattern": "<string>",
    "format": "date-time",
    "required": [
      "<string>"
    ],
    "enum": [
      "<string>"
    ],
    "title": "<string>"
  },
  "backoffPlan": {
    "type": "fixed",
    "maxRetries": 0,
    "baseDelaySeconds": 1
  },
  "variableExtractionPlan": {
    "schema": {
      "type": "string",
      "items": {},
      "properties": {},
      "description": "<string>",
      "pattern": "<string>",
      "format": "date-time",
      "required": [
        "<string>"
      ],
      "enum": [
        "<string>"
      ],
      "title": "<string>"
    },
    "aliases": [
      {
        "key": "<string>",
        "value": "<string>"
      }
    ]
  },
  "function": {
    "name": "<string>",
    "strict": false,
    "description": "<string>",
    "parameters": {
      "type": "object",
      "properties": {},
      "required": [
        "<string>"
      ]
    }
  }
}
'
{
  "type": "apiRequest",
  "method": "POST",
  "id": "<string>",
  "orgId": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "url": "<string>",
  "messages": [
    {
      "type": "request-start",
      "contents": [
        {
          "type": "text",
          "text": "<string>",
          "language": "aa"
        }
      ],
      "blocking": false,
      "content": "<string>",
      "conditions": [
        {
          "operator": "eq",
          "param": "<string>",
          "value": "<string>"
        }
      ]
    }
  ],
  "timeoutSeconds": 20,
  "function": {
    "name": "<string>",
    "strict": false,
    "description": "<string>",
    "parameters": {
      "type": "object",
      "properties": {},
      "required": [
        "<string>"
      ]
    }
  },
  "name": "<string>",
  "description": "<string>",
  "body": {
    "type": "string",
    "items": {},
    "properties": {},
    "description": "<string>",
    "pattern": "<string>",
    "format": "date-time",
    "required": [
      "<string>"
    ],
    "enum": [
      "<string>"
    ],
    "title": "<string>"
  },
  "headers": {
    "type": "string",
    "items": {},
    "properties": {},
    "description": "<string>",
    "pattern": "<string>",
    "format": "date-time",
    "required": [
      "<string>"
    ],
    "enum": [
      "<string>"
    ],
    "title": "<string>"
  },
  "backoffPlan": {
    "type": "fixed",
    "maxRetries": 0,
    "baseDelaySeconds": 1
  },
  "variableExtractionPlan": {
    "schema": {
      "type": "string",
      "items": {},
      "properties": {},
      "description": "<string>",
      "pattern": "<string>",
      "format": "date-time",
      "required": [
        "<string>"
      ],
      "enum": [
        "<string>"
      ],
      "title": "<string>"
    },
    "aliases": [
      {
        "key": "<string>",
        "value": "<string>"
      }
    ]
  }
}

Authorizations

Authorization
string
header
required

Retrieve your API Key from Dashboard.

Body

application/json
  • ApiRequestTool
  • DtmfTool
  • EndCallTool
  • FunctionTool
  • GhlTool
  • MakeTool
  • TransferCallTool
  • OutputTool
  • BashTool
  • ComputerTool
  • TextEditorTool
  • QueryTool
  • GoogleCalendarCreateEventTool
  • GoogleSheetsRowAppendTool
  • GoogleCalendarCheckAvailabilityTool
  • SlackSendMessageTool
  • SmsSendTool
  • McpTool
  • GoHighLevelCalendarAvailabilityTool
  • GoHighLevelCalendarEventCreateTool
  • GoHighLevelContactCreateTool
  • GoHighLevelContactGetTool
type
enum<string>
required

The type of tool. "apiRequest" for API request tool.

Available options:
apiRequest
method
enum<string>
required
Available options:
POST,
GET
url
string
required

This is where the request will be sent.

messages
(ToolMessageStart · object | ToolMessageComplete · object | ToolMessageFailed · object | ToolMessageDelayed · object)[]

These are the messages that will be spoken to the user as the tool is running.

For some tools, this is auto-filled based on special fields like tool.destinations. For others like the function tool, these can be custom configured.

  • ToolMessageStart
  • ToolMessageComplete
  • ToolMessageFailed
  • ToolMessageDelayed
timeoutSeconds
number

This is the timeout in seconds for the request. Defaults to 20 seconds.

@default 20

Required range: 1 <= x <= 300
Example:

20

name
string

This is the name of the tool. This will be passed to the model.

Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 40.

Maximum string length: 40
description
string

This is the description of the tool. This will be passed to the model.

Maximum string length: 1000
body
object

This is the body of the request.

headers
object

These are the headers to send in the request.

backoffPlan
object

This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried).

@default undefined (the request will not be retried)

variableExtractionPlan
object

This is the plan to extract variables from the tool's response. These will be accessible during the call and stored in call.artifact.variableValues after the call.

Usage:

  1. Use aliases to extract variables from the tool's response body. (Most common case)
{
"aliases": [
{
"key": "customerName",
"value": "{{customer.name}}"
},
{
"key": "customerAge",
"value": "{{customer.age}}"
}
]
}

The tool response body is made available to the liquid template.

  1. Use aliases to extract variables from the tool's response body if the response is an array.
{
"aliases": [
{
"key": "customerName",
"value": "{{$[0].name}}"
},
{
"key": "customerAge",
"value": "{{$[0].age}}"
}
]
}

$ is a shorthand for the tool's response body. $[0] is the first item in the array. $[n] is the nth item in the array. Note, $ is available regardless of the response body type (both object and array).

  1. Use aliases to extract variables from the tool's response headers.
{
"aliases": [
{
"key": "customerName",
"value": "{{tool.response.headers.customer-name}}"
},
{
"key": "customerAge",
"value": "{{tool.response.headers.customer-age}}"
}
]
}

tool.response is made available to the liquid template. Particularly, both tool.response.headers and tool.response.body are available. Note, tool.response is available regardless of the response body type (both object and array).

  1. Use schema to extract a large portion of the tool's response body.

4.1. If you hit example.com and it returns {"name": "John", "age": 30}, then you can specify the schema as:

{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "number"
}
}
}
}

4.2. If you hit example.com and it returns {"name": {"first": "John", "last": "Doe"}}, then you can specify the schema as:

{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "object",
"properties": {
"first": {
"type": "string"
},
"last": {
"type": "string"
}
}
}
}
}
}

These will be extracted as {{ name }} and {{ age }} respectively. To emphasize, object properties are extracted as direct global variables.

4.3. If you hit example.com and it returns {"name": {"first": "John", "last": "Doe"}}, then you can specify the schema as:

{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "object",
"properties": {
"first": {
"type": "string"
},
"last": {
"type": "string"
}
}
}
}
}
}

These will be extracted as {{ name }}. And, {{ name.first }} and {{ name.last }} will be accessible.

4.4. If you hit example.com and it returns ["94123", "94124"], then you can specify the schema as:

{
"schema": {
"type": "array",
"title": "zipCodes",
"items": {
"type": "string"
}
}
}

This will be extracted as {{ zipCodes }}. To access the array items, you can use {{ zipCodes[0] }} and {{ zipCodes[1] }}.

4.5. If you hit example.com and it returns [{"name": "John", "age": 30, "zipCodes": ["94123", "94124"]}, {"name": "Jane", "age": 25, "zipCodes": ["94125", "94126"]}], then you can specify the schema as:

{
"schema": {
"type": "array",
"title": "people",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "number"
},
"zipCodes": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}

This will be extracted as {{ people }}. To access the array items, you can use {{ people[n].name }}, {{ people[n].age }}, {{ people[n].zipCodes }}, {{ people[n].zipCodes[0] }} and {{ people[n].zipCodes[1] }}.

Note: Both aliases and schema can be used together.

function
object

This is the function definition of the tool.

For endCall, transferCall, and dtmf tools, this is auto-filled based on tool-specific fields like tool.destinations. But, even in those cases, you can provide a custom function definition for advanced use cases.

An example of an advanced use case is if you want to customize the message that's spoken for endCall tool. You can specify a function where it returns an argument "reason". Then, in messages array, you can have many "request-complete" messages. One of these messages will be triggered if the messages[].conditions matches the "reason" argument.

Response

201 - application/json
  • ApiRequestTool
  • DtmfTool
  • EndCallTool
  • FunctionTool
  • GhlTool
  • MakeTool
  • TransferCallTool
  • OutputTool
  • BashTool
  • ComputerTool
  • TextEditorTool
  • QueryTool
  • GoogleCalendarCreateEventTool
  • GoogleSheetsRowAppendTool
  • GoogleCalendarCheckAvailabilityTool
  • SlackSendMessageTool
  • SmsSendTool
  • McpTool
  • GoHighLevelCalendarAvailabilityTool
  • GoHighLevelCalendarEventCreateTool
  • GoHighLevelContactCreateTool
  • GoHighLevelContactGetTool
type
enum<string>
required

The type of tool. "apiRequest" for API request tool.

Available options:
apiRequest
method
enum<string>
required
Available options:
POST,
GET
id
string
required

This is the unique identifier for the tool.

orgId
string
required

This is the unique identifier for the organization that this tool belongs to.

createdAt
string<date-time>
required

This is the ISO 8601 date-time string of when the tool was created.

updatedAt
string<date-time>
required

This is the ISO 8601 date-time string of when the tool was last updated.

url
string
required

This is where the request will be sent.

messages
(ToolMessageStart · object | ToolMessageComplete · object | ToolMessageFailed · object | ToolMessageDelayed · object)[]

These are the messages that will be spoken to the user as the tool is running.

For some tools, this is auto-filled based on special fields like tool.destinations. For others like the function tool, these can be custom configured.

  • ToolMessageStart
  • ToolMessageComplete
  • ToolMessageFailed
  • ToolMessageDelayed
timeoutSeconds
number

This is the timeout in seconds for the request. Defaults to 20 seconds.

@default 20

Required range: 1 <= x <= 300
Example:

20

function
object

This is the function definition of the tool.

For endCall, transferCall, and dtmf tools, this is auto-filled based on tool-specific fields like tool.destinations. But, even in those cases, you can provide a custom function definition for advanced use cases.

An example of an advanced use case is if you want to customize the message that's spoken for endCall tool. You can specify a function where it returns an argument "reason". Then, in messages array, you can have many "request-complete" messages. One of these messages will be triggered if the messages[].conditions matches the "reason" argument.

name
string

This is the name of the tool. This will be passed to the model.

Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 40.

Maximum string length: 40
description
string

This is the description of the tool. This will be passed to the model.

Maximum string length: 1000
body
object

This is the body of the request.

headers
object

These are the headers to send in the request.

backoffPlan
object

This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried).

@default undefined (the request will not be retried)

variableExtractionPlan
object

This is the plan to extract variables from the tool's response. These will be accessible during the call and stored in call.artifact.variableValues after the call.

Usage:

  1. Use aliases to extract variables from the tool's response body. (Most common case)
{
"aliases": [
{
"key": "customerName",
"value": "{{customer.name}}"
},
{
"key": "customerAge",
"value": "{{customer.age}}"
}
]
}

The tool response body is made available to the liquid template.

  1. Use aliases to extract variables from the tool's response body if the response is an array.
{
"aliases": [
{
"key": "customerName",
"value": "{{$[0].name}}"
},
{
"key": "customerAge",
"value": "{{$[0].age}}"
}
]
}

$ is a shorthand for the tool's response body. $[0] is the first item in the array. $[n] is the nth item in the array. Note, $ is available regardless of the response body type (both object and array).

  1. Use aliases to extract variables from the tool's response headers.
{
"aliases": [
{
"key": "customerName",
"value": "{{tool.response.headers.customer-name}}"
},
{
"key": "customerAge",
"value": "{{tool.response.headers.customer-age}}"
}
]
}

tool.response is made available to the liquid template. Particularly, both tool.response.headers and tool.response.body are available. Note, tool.response is available regardless of the response body type (both object and array).

  1. Use schema to extract a large portion of the tool's response body.

4.1. If you hit example.com and it returns {"name": "John", "age": 30}, then you can specify the schema as:

{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "number"
}
}
}
}

4.2. If you hit example.com and it returns {"name": {"first": "John", "last": "Doe"}}, then you can specify the schema as:

{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "object",
"properties": {
"first": {
"type": "string"
},
"last": {
"type": "string"
}
}
}
}
}
}

These will be extracted as {{ name }} and {{ age }} respectively. To emphasize, object properties are extracted as direct global variables.

4.3. If you hit example.com and it returns {"name": {"first": "John", "last": "Doe"}}, then you can specify the schema as:

{
"schema": {
"type": "object",
"properties": {
"name": {
"type": "object",
"properties": {
"first": {
"type": "string"
},
"last": {
"type": "string"
}
}
}
}
}
}

These will be extracted as {{ name }}. And, {{ name.first }} and {{ name.last }} will be accessible.

4.4. If you hit example.com and it returns ["94123", "94124"], then you can specify the schema as:

{
"schema": {
"type": "array",
"title": "zipCodes",
"items": {
"type": "string"
}
}
}

This will be extracted as {{ zipCodes }}. To access the array items, you can use {{ zipCodes[0] }} and {{ zipCodes[1] }}.

4.5. If you hit example.com and it returns [{"name": "John", "age": 30, "zipCodes": ["94123", "94124"]}, {"name": "Jane", "age": 25, "zipCodes": ["94125", "94126"]}], then you can specify the schema as:

{
"schema": {
"type": "array",
"title": "people",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "number"
},
"zipCodes": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}

This will be extracted as {{ people }}. To access the array items, you can use {{ people[n].name }}, {{ people[n].age }}, {{ people[n].zipCodes }}, {{ people[n].zipCodes[0] }} and {{ people[n].zipCodes[1] }}.

Note: Both aliases and schema can be used together.