> ## 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 bookable target

> Only for a connection whose `capabilities.roarkOwnsBookingPolicy` is true. A calendar with no scheduling of its own has nothing an agent can be pointed at, so the thing a calendar tool books into is created here: the calendar, how long an appointment runs, and the hours it is offered in. The policy and the hours are written together, because a target with no hours offers nothing. Refused if the calendar is one the account can only read.



## OpenAPI

````yaml /api-reference/openapi.documented.json post /v1/integrations/calendar/{connectionId}/targets
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: Agent
  - name: Customer
  - name: Agent Endpoint
  - name: Tool
  - name: Phone Number
  - name: Call
  - name: Chat
  - name: Conversation
  - name: Metric
  - name: Metric Policy
  - name: Metric Collection Job
  - name: Customer Flow
  - name: Customer Flow Edge Case
  - name: Simulation
  - name: Simulation Persona
  - name: Simulation Environment
  - name: Simulation Scenario
  - name: Simulation Run Plan
  - name: Simulation Template
  - name: Simulation Audio Clip
  - name: Simulation Run Plan Job
  - name: Simulation Job
  - name: HTTP Request Definition
  - name: Webhook
  - name: Issue
  - name: Autoimprove
  - name: Agent Config
  - name: Knowledge Base
  - name: Calendar Integration
  - name: MCP Server Integration
  - name: Config
  - name: Organization Project
  - name: Organization Project Member
  - name: Organization Project API Key
  - name: Organization Config
  - name: CLI Auth
  - name: Me
  - name: Project
  - name: Usage
  - name: Analytics
  - name: Dashboard
  - name: Live Report
  - name: Benchmark
  - name: Health
  - name: Campaign Credit
paths:
  /v1/integrations/calendar/{connectionId}/targets:
    post:
      tags:
        - Calendar Integration
      summary: Create a bookable target
      description: >-
        Only for a connection whose `capabilities.roarkOwnsBookingPolicy` is
        true. A calendar with no scheduling of its own has nothing an agent can
        be pointed at, so the thing a calendar tool books into is created here:
        the calendar, how long an appointment runs, and the hours it is offered
        in. The policy and the hours are written together, because a target with
        no hours offers nothing. Refused if the calendar is one the account can
        only read.
      operationId: postV1IntegrationsCalendarByConnectionIdTargets
      parameters:
        - name: connectionId
          in: path
          required: true
          schema:
            type: string
          description: Calendar connection ID
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: >-
                    Unique within the connection, and how a config file refers
                    to this target. Letters, digits, spaces, _ or -.
                  example: Front desk
                calendarId:
                  type: string
                  minLength: 1
                  description: >-
                    The calendar to write appointments to, from `GET
                    /v1/integrations/calendar/{connectionId}/calendars`.
                    `primary` is accepted and stored as the account’s own id.
                  example: clinic@example.com
                durationMinutes:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 1440
                  example: 30
                bufferBeforeMinutes:
                  type:
                    - integer
                    - 'null'
                  minimum: 0
                  maximum: 1440
                  description: >-
                    Dead time before an appointment, counted as busy when a slot
                    is offered. Defaults to 0.
                bufferAfterMinutes:
                  type:
                    - integer
                    - 'null'
                  minimum: 0
                  maximum: 1440
                minNoticeMinutes:
                  type:
                    - integer
                    - 'null'
                  minimum: 0
                  maximum: 525600
                  description: >-
                    How soon from now an appointment may be made. Defaults to
                    120.
                horizonDays:
                  type:
                    - integer
                    - 'null'
                  exclusiveMinimum: 0
                  maximum: 365
                  description: How far ahead appointments may be made. Defaults to 30.
                slotIntervalMinutes:
                  type:
                    - integer
                    - 'null'
                  exclusiveMinimum: 0
                  maximum: 1440
                  description: >-
                    The grid slots are offered on. Defaults to the duration,
                    which gives back-to-back appointments.
                allDayEventsBlock:
                  type:
                    - boolean
                    - 'null'
                  description: >-
                    Whether an all-day event closes the day. Defaults to true,
                    because a calendar marks all-day events free unless their
                    creator says otherwise and a public holiday entered as one
                    would otherwise be bookable.
                hours:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      weekday:
                        type: integer
                        minimum: 1
                        maximum: 7
                        description: 'ISO weekday: Monday is 1, Sunday is 7.'
                      startMinute:
                        type: integer
                        minimum: 0
                        maximum: 1439
                        description: >-
                          Minutes from local midnight, in the connection’s
                          timezone.
                      endMinute:
                        type: integer
                        minimum: 1
                        maximum: 1440
                    required:
                      - weekday
                      - startMinute
                      - endMinute
                    title: BookableHours
                    description: >-
                      One window of the week appointments are offered in. A
                      window that runs past midnight is two entries on two
                      weekdays; a day the business is closed is simply absent.
                  minItems: 1
                  maxItems: 42
                  description: >-
                    The windows of the week appointments are offered in. Omit to
                    adopt Monday to Friday, 09:00 to 17:00. A target with no
                    windows offers nothing at all, which reads to a caller as a
                    permanently full diary.
              required:
                - name
                - calendarId
                - durationMinutes
              title: CreateBookableTargetInput
              description: >-
                A bookable target to create on a connection whose provider has
                no scheduling of its own.
      responses:
        '201':
          description: The target, in the same shape `GET /targets` lists.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: >-
                          Identifier within this connection. Pass it back to
                          read one target in detail.
                      label:
                        type: string
                        description: What the customer called it on the provider.
                      durationMinutes:
                        type:
                          - number
                          - 'null'
                        description: >-
                          How long an appointment runs, when the provider fixes
                          one length.
                      durationOptions:
                        type: array
                        items:
                          type: number
                        description: >-
                          Other lengths this target offers, when it offers a
                          choice. A calendar tool pins one of these with
                          `durationMinutes`; an empty list means the length is
                          not the customer’s to choose.
                      requiresConfirmation:
                        type: boolean
                        description: >-
                          A human has to accept before it is an appointment. An
                          agent booking one of these must say "requested", never
                          "confirmed".
                      isHidden:
                        type: boolean
                        description: >-
                          Hidden on the provider’s own booking page. Still
                          bookable through this API.
                      policy:
                        type:
                          - object
                          - 'null'
                        properties:
                          durationMinutes:
                            type: integer
                          bufferBeforeMinutes:
                            type: integer
                            description: Dead time before an appointment, counted as busy.
                          bufferAfterMinutes:
                            type: integer
                          minNoticeMinutes:
                            type: integer
                            description: How soon from now an appointment may be made.
                          horizonDays:
                            type: integer
                            description: How far ahead appointments may be made.
                          slotIntervalMinutes:
                            type: integer
                            description: >-
                              The grid slots are offered on, measured from each
                              bookable window’s own start rather than the hour.
                          allDayEventsBlock:
                            type: boolean
                            description: >-
                              Whether an all-day event closes the day. On by
                              default: a calendar marks all-day events free
                              unless their creator says otherwise, so a public
                              holiday entered as one would otherwise still be
                              bookable.
                          hours:
                            type: array
                            items:
                              type: object
                              properties:
                                weekday:
                                  type: integer
                                  minimum: 1
                                  maximum: 7
                                  description: 'ISO weekday: Monday is 1, Sunday is 7.'
                                startMinute:
                                  type: integer
                                  minimum: 0
                                  maximum: 1439
                                  description: >-
                                    Minutes from local midnight, in the
                                    connection’s timezone.
                                endMinute:
                                  type: integer
                                  minimum: 1
                                  maximum: 1440
                              required:
                                - weekday
                                - startMinute
                                - endMinute
                              title: BookableHours
                              description: >-
                                One window of the week appointments are offered
                                in. A window that runs past midnight is two
                                entries on two weekdays; a day the business is
                                closed is simply absent.
                        required:
                          - durationMinutes
                          - bufferBeforeMinutes
                          - bufferAfterMinutes
                          - minNoticeMinutes
                          - horizonDays
                          - slotIntervalMinutes
                          - allDayEventsBlock
                          - hours
                        title: BookableTargetPolicy
                        description: >-
                          The booking policy Roark applies, for a calendar with
                          no scheduling of its own. Null on a scheduling system,
                          which owns its own rules, so this one field says which
                          kind of provider you are looking at without matching
                          on the provider name.
                      target:
                        anyOf:
                          - type: object
                            properties:
                              provider:
                                type: string
                                const: CAL_COM
                              eventTypeId:
                                type: integer
                                exclusiveMinimum: 0
                            required:
                              - provider
                              - eventTypeId
                          - type: object
                            properties:
                              provider:
                                type: string
                                const: GOOGLE
                              targetId:
                                type: string
                                format: uuid
                              calendarId:
                                type: string
                            required:
                              - provider
                              - targetId
                              - calendarId
                        title: BookableTargetRef
                        description: >-
                          Ready to put on a calendar tool, so nothing has to
                          assemble one by hand.
                    required:
                      - id
                      - label
                      - durationMinutes
                      - durationOptions
                      - requiresConfirmation
                      - isHidden
                      - policy
                      - target
                    title: BookableTarget
                    description: >-
                      Something on a connected account an agent can be pointed
                      at: a Cal.com event type, or a bookable target on a
                      calendar whose booking policy Roark owns.
                required:
                  - data
        '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 response = await
            client.calendarConnection.createTarget('connectionId', {
              calendarId: 'clinic@example.com',
              durationMinutes: 30,
              name: 'Front desk',
            });


            console.log(response.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
            )
            response = client.calendar_connection.create_target(
                connection_id="connectionId",
                calendar_id="clinic@example.com",
                duration_minutes=30,
                name="Front desk",
            )
            print(response.data)
components:
  schemas:
    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
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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