> ## Documentation Index
> Fetch the complete documentation index at: https://docs.roark.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a tool

> Creates a tool and declares its first version. A tool only recorded from calls under the same name is adopted; one already declared returns 409. Give it a `runtime` for a hosted agent to call your endpoint, a `calendar` for it to book on a calendar connected to the project, or `mcp` for it to call a tool on an MCP server connected to the project. Header values are returned on read, so keep secrets out of them.



## OpenAPI

````yaml /api-reference/openapi.documented.json post /v1/tool
openapi: 3.1.0
info:
  title: Roark Analytics API
  description: >-
    The Roark Analytics API gives you access to the same API that powers the
    award winning Roark Analytics platform.
  version: 1.0.0
servers:
  - description: Production
    url: https://api.roark.ai
security:
  - Bearer: []
tags:
  - name: Health
    x-displayName: Health
  - name: Authentication
    x-displayName: Current credential
  - name: Project API Key
    x-displayName: Project API keys
  - name: Personal API Key
    x-displayName: Personal API keys
  - name: Agent
    x-displayName: Agents
  - name: Agent Endpoint
    x-displayName: Endpoints
  - name: Tool
    x-displayName: Tools
  - name: Autoimprove
    x-displayName: Autoimprove
  - name: Generate Simulation Resources
    x-displayName: Generate resources
  - name: Customer Flow
    x-displayName: Customer flows
  - name: Customer Flow Folder
    x-displayName: Customer flow folders
  - name: Simulation Persona
    x-displayName: Personas
  - name: Simulation Environment
    x-displayName: Environments
  - name: Simulation Template
    x-displayName: Templates
  - name: Simulation Run Plan
    x-displayName: Plans
  - name: Simulation Run
    x-displayName: Runs
  - name: Simulation Tool Mock
    x-displayName: Tool mocks and fixtures
  - name: Simulation Phone Number
    x-displayName: Simulation phone numbers
  - name: Metric
    x-displayName: Definitions
  - name: Metric Variant
    x-displayName: Variants
  - name: Metric Policy
    x-displayName: Policies
  - name: Metric Collection Job
    x-displayName: Collection jobs
  - name: Call
    x-displayName: Calls
  - name: Chat
    x-displayName: Chats
  - name: Customer
    x-displayName: Customers
  - name: Issue
    x-displayName: Issues
  - name: Analytics
    x-displayName: Analytics
  - name: Dashboard
    x-displayName: Dashboards & widgets
  - name: Live Report
    x-displayName: Live reports
  - name: Agent Connection
    x-displayName: Agent platforms
  - name: Calendar Connection
    x-displayName: Calendars
  - name: MCP Server Connection
    x-displayName: MCP servers
  - name: Knowledge Base
    x-displayName: Knowledge bases
  - name: HTTP Request Definition
    x-displayName: HTTP request definitions
  - name: Webhook
    x-displayName: Webhooks
  - name: Config
    x-displayName: Config as code
  - name: Organization Project
    x-displayName: Projects
  - name: Organization Project Member
    x-displayName: Project members
  - name: Usage
    x-displayName: Usage
  - name: Benchmark
    x-displayName: Model benchmarks
paths:
  /v1/tool:
    post:
      tags:
        - Tool
      summary: Create a tool
      description: >-
        Creates a tool and declares its first version. A tool only recorded from
        calls under the same name is adopted; one already declared returns 409.
        Give it a `runtime` for a hosted agent to call your endpoint, a
        `calendar` for it to book on a calendar connected to the project, or
        `mcp` for it to call a tool on an MCP server connected to the project.
        Header values are returned on read, so keep secrets out of them.
      operationId: postV1Tool
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToolBody'
      responses:
        '201':
          description: The tool
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolSingleResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Validation error
              example:
                type: validation
                code: invalid_parameter
                message: The request was invalid
                param: email
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Authentication error
              example:
                type: authentication
                code: unauthorized
                message: Authentication required
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Not found error
              example:
                type: not_found
                code: resource_not_found
                message: The requested resource could not be found
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Conflict error
              example:
                type: conflict
                code: resource_in_use
                message: The resource is in use and cannot be deleted
          description: Conflict
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Server error
              example:
                type: internal
                code: internal_error
                message: Internal server error
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Roark from '@roarkanalytics/sdk';


            const client = new Roark({
              bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
            });


            const tool = await client.tool.create({ description: 'x', name:
            'book_appointment' });


            console.log(tool.data);
        - lang: Python
          source: |-
            import os
            from roark_analytics import Roark

            client = Roark(
                bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"),  # This is the default and can be omitted
            )
            tool = client.tool.create(
                description="x",
                name="book_appointment",
            )
            print(tool.data)
components:
  schemas:
    ToolBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 64
          example: book_appointment
        description:
          type: string
          minLength: 1
          maxLength: 1024
          description: When the agent should use the tool
        agentId:
          type:
            - string
            - 'null'
          format: uuid
        inputs:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 64
                example: date
              type:
                type: string
                enum:
                  - string
                  - number
                  - boolean
              description:
                type: string
                maxLength: 1024
              required:
                type: boolean
                default: false
            required:
              - name
              - type
          maxItems: 32
          default: []
        invocationCriteria:
          type:
            - string
            - 'null'
        expectedResult:
          type:
            - string
            - 'null'
        runtime:
          type:
            - object
            - 'null'
          properties:
            request:
              type: object
              properties:
                url:
                  type: string
                  format: uri
                  maxLength: 2048
                method:
                  type: string
                  enum:
                    - POST
                    - PUT
                    - PATCH
                    - GET
                    - DELETE
                  default: POST
                headers:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 128
                        example: X-Api-Version
                      value:
                        type: string
                        maxLength: 1024
                        example: '2026-10-01'
                    required:
                      - name
                      - value
                  maxItems: 32
                  default: []
                body:
                  type:
                    - string
                    - 'null'
                  minLength: 1
                  maxLength: 16000
                timeoutMs:
                  type:
                    - integer
                    - 'null'
                  minimum: 1000
                  maximum: 30000
              required:
                - url
            changesData:
              type: boolean
              default: false
            responseFields:
              type:
                - array
                - 'null'
              items:
                type: string
                minLength: 1
                maxLength: 256
              minItems: 1
              maxItems: 32
            messages:
              type: object
              properties:
                before:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                slow:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                failure:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
          required:
            - request
          description: Omit or null for a tool that is only graded
        calendar:
          type:
            - object
            - 'null'
          properties:
            calendarConnectionId:
              type: string
              format: uuid
            operation:
              type: string
              enum:
                - CHECK_AVAILABILITY
                - BOOK
                - LOOKUP_BOOKING
                - RESCHEDULE
                - CANCEL
                - LIST_BOOKINGS
            appointmentTypes:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    minLength: 1
                    maxLength: 64
                    example: checkup
                  whenToUse:
                    type:
                      - string
                      - 'null'
                    minLength: 1
                    maxLength: 500
                  eventTypeId:
                    type:
                      - integer
                      - 'null'
                    exclusiveMinimum: 0
                    description: 'For Cal.com: the event type to book'
                  calendarTargetId:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    description: >-
                      For a calendar with no scheduling of its own: the bookable
                      target to book into
                  eventTypeUri:
                    type:
                      - string
                      - 'null'
                    pattern: >-
                      ^https:\/\/(?:[a-z0-9-]+\.)+calendly\.com\/event_types\/[A-Za-z0-9-]+$
                    maxLength: 512
                    description: 'For Calendly: the event type to book, by URI'
                  goHighLevelCalendar:
                    type:
                      - string
                      - 'null'
                    pattern: ^[A-Za-z0-9_-]+$
                    minLength: 1
                    maxLength: 64
                    description: 'For GoHighLevel: the calendar to book into, by its own id'
                  durationMinutes:
                    type:
                      - integer
                      - 'null'
                    exclusiveMinimum: 0
                    maximum: 1440
                required:
                  - name
              minItems: 1
              maxItems: 24
            simulate:
              type: boolean
              default: false
            messages:
              type: object
              properties:
                before:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                slow:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                failure:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
          required:
            - calendarConnectionId
            - operation
            - appointmentTypes
          description: >-
            Makes this a calendar tool, which Roark runs against a connected
            calendar: it takes no runtime and no inputs. Omit or null for any
            other tool; on update, omitting it makes the tool an ordinary one.
        mcp:
          type:
            - object
            - 'null'
          properties:
            mcpServerId:
              type: string
              format: uuid
            tool:
              type: string
              minLength: 1
              maxLength: 128
              description: The tool as the server names it
            messages:
              type: object
              properties:
                before:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                slow:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
                failure:
                  type:
                    - string
                    - 'null'
                  maxLength: 500
          required:
            - mcpServerId
            - tool
          description: >-
            Makes this a tool on one of the project's MCP servers: it takes no
            runtime, no inputs and no calendar, and the description replaces the
            server's own. On update, omitting it makes the tool an ordinary one.
      required:
        - name
        - description
    ToolSingleResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/ToolResponse'
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - validation
            - authentication
            - forbidden
            - not_found
            - conflict
            - payment_required
            - rate_limit
            - internal
          description: The error type category
          examples:
            - validation
            - authentication
        code:
          type: string
          description: Machine-readable error code identifier
          examples:
            - invalid_parameter
            - missing_required_field
            - unauthorized
        message:
          type: string
          description: Human-readable error message
          examples:
            - The request was invalid
            - Authentication required
        param:
          type: string
          description: The parameter that caused the error (if applicable)
          examples:
            - email
            - user_id
        details:
          description: Additional error context information
      required:
        - type
        - code
        - message
    ToolResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          example: book_appointment
        source:
          type: string
          enum:
            - CUSTOM
            - SYSTEM
          description: SYSTEM for a built-in tool every project can attach
        systemKey:
          type:
            - string
            - 'null'
          description: The stable key of a built-in tool, such as dtmf
        agentId:
          type:
            - string
            - 'null'
          format: uuid
          description: The agent the tool is scoped to; null for the project
        version:
          type:
            - integer
            - 'null'
          description: The latest version; null before any is declared
        description:
          type:
            - string
            - 'null'
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/ToolInput'
        invocationCriteria:
          type:
            - string
            - 'null'
          description: When the agent should call it, for grading
        expectedResult:
          type:
            - string
            - 'null'
          description: How it should handle the result, for grading
        runtime:
          oneOf:
            - $ref: '#/components/schemas/ToolRuntime'
            - type: 'null'
          description: Null for a tool that is only graded
        calendar:
          oneOf:
            - $ref: '#/components/schemas/ToolCalendar'
            - type: 'null'
          description: Null for every tool that is not a calendar tool
        mcp:
          oneOf:
            - $ref: '#/components/schemas/ToolMcp'
            - type: 'null'
          description: Null for every tool that is not an MCP tool
        createdAt:
          type: string
        updatedAt:
          type: string
      required:
        - id
        - name
        - source
        - systemKey
        - agentId
        - version
        - description
        - inputs
        - invocationCriteria
        - expectedResult
        - runtime
        - calendar
        - mcp
        - createdAt
        - updatedAt
    ToolInput:
      type: object
      properties:
        name:
          type: string
          description: The input name, as the agent passes it
          example: date
        type:
          type: string
          enum:
            - string
            - number
            - boolean
          description: string, number or boolean
        description:
          type:
            - string
            - 'null'
          description: What the input is, so the agent fills it in right
          example: ISO date
        required:
          type: boolean
          description: The agent must pass it
      required:
        - name
        - type
        - description
        - required
    ToolRuntime:
      type: object
      properties:
        request:
          $ref: '#/components/schemas/ToolRequest'
        changesData:
          type: boolean
          description: >-
            The tool books, cancels or sends something: its call is not
            abandoned when the caller interrupts, and each request carries an
            Idempotency-Key.
        responseFields:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Dot paths into the JSON response the agent is given. Null gives it
            the whole response.
        messages:
          $ref: '#/components/schemas/ToolMessages'
      required:
        - request
        - changesData
        - responseFields
        - messages
      description: What a hosted agent sends and says when it calls the tool
    ToolCalendar:
      type: object
      properties:
        calendarConnectionId:
          type: string
          format: uuid
          description: The connected calendar the tool books on
        operation:
          type: string
          enum:
            - CHECK_AVAILABILITY
            - BOOK
            - LOOKUP_BOOKING
            - RESCHEDULE
            - CANCEL
            - LIST_BOOKINGS
          description: The one action this tool takes on the calendar
        appointmentTypes:
          type: array
          items:
            $ref: '#/components/schemas/ToolCalendarAppointmentType'
          description: The kinds of appointment the tool may reach
        simulate:
          type: boolean
          description: Every call books on a simulated calendar instead of the customer's
        messages:
          $ref: '#/components/schemas/ToolMessages'
      required:
        - calendarConnectionId
        - operation
        - appointmentTypes
        - simulate
        - messages
      description: What a calendar tool books into. Roark runs it; it has no runtime.
    ToolMcp:
      type: object
      properties:
        mcpServerId:
          type: string
          format: uuid
          description: The MCP server the tool calls
        tool:
          type: string
          description: The tool as the server names it
          example: search_customers
        messages:
          $ref: '#/components/schemas/ToolMessages'
      required:
        - mcpServerId
        - tool
        - messages
      description: >-
        A tool on one of the project's MCP servers. The server runs it and
        defines its arguments.
    ToolRequest:
      type: object
      properties:
        url:
          type: string
          description: >-
            https URL. Placeholders {{args.<input>}} and {{conversation.*}} (id,
            direction, modality, agentNumber, customerNumber, startedAt) may
            appear in the path and query.
          example: https://api.example.com/bookings
        method:
          type: string
          enum:
            - POST
            - PUT
            - PATCH
            - GET
            - DELETE
        headers:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 128
                example: X-Api-Version
              value:
                type: string
                maxLength: 1024
                example: '2026-10-01'
            required:
              - name
              - value
        body:
          type:
            - string
            - 'null'
          description: >-
            JSON body template. Null sends the inputs as the body (POST, PUT,
            PATCH) or the query (GET, DELETE).
        timeoutMs:
          type:
            - integer
            - 'null'
          description: How long the agent waits, 1000 to 30000 ms
      required:
        - url
        - method
        - headers
        - body
        - timeoutMs
    ToolMessages:
      type: object
      properties:
        before:
          type:
            - string
            - 'null'
          description: Said as the request goes out
        slow:
          type:
            - string
            - 'null'
          description: Said once if the request is slow
        failure:
          type:
            - string
            - 'null'
          description: Given to the agent to say when the request fails
      required:
        - before
        - slow
        - failure
    ToolCalendarAppointmentType:
      type: object
      properties:
        name:
          type: string
          description: What the agent passes to name it
          example: checkup
        whenToUse:
          type:
            - string
            - 'null'
          description: The line that tells the agent when it applies
        eventTypeId:
          type:
            - integer
            - 'null'
          description: 'For Cal.com: the event type it books'
        calendarTargetId:
          type:
            - string
            - 'null'
          description: >-
            For a calendar with no scheduling of its own: the bookable target it
            books into, which carries the duration, buffers, notice, horizon and
            weekly hours
        eventTypeUri:
          type:
            - string
            - 'null'
          description: 'For Calendly: the event type it books, which Calendly names by URI'
        goHighLevelCalendar:
          type:
            - string
            - 'null'
          description: 'For GoHighLevel: the calendar it books into, by its own id'
        durationMinutes:
          type:
            - integer
            - 'null'
          description: Only for an event type offering several durations
      required:
        - name
        - whenToUse
        - eventTypeId
        - calendarTargetId
        - eventTypeUri
        - goHighLevelCalendar
        - durationMinutes
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.