# Add a post-call action (/docs/api-reference/agents/addPostCallAction)

> Add one post-call action to the agent. The agent's other actions are not changed. Send an `Idempotency-Key` header to make a retry safe: the same key and body return the action the first request added.

**POST** `/agents/{agent_id}/post-call-actions`

Add one post-call action to the agent. The agent's other actions are not changed. Send an `Idempotency-Key` header to make a retry safe: the same key and body return the action the first request added.

```yaml
operationId: addPostCallAction
parameters:
  - name: Idempotency-Key
    in: header
    required: false
    schema:
      type: string
    description: Any unique string. A retry with the same key and body adds nothing new.
requestBody:
  required: true
  content:
    application/json:
      schema:
        type: object
        description: |
          One post-call action. `type` picks the channel; send the fields of
          that channel plus any of the shared ones. `type` is required when
          adding an action; an update sends only the fields it changes.
        properties:
          user_id:
            type: integer
            description: |
              Reseller keys only: act as one of your clients by its user id. Omit
              it to act on your own account.
              [How acting for a client works](/docs/reseller/your-clients/acting-as-clients).
            example: 1234
          type:
            type: string
            enum:
              - email
              - webhook
              - omni_crm
              - cloud_whatsapp
              - workflow
              - google_sheets
              - slack
              - salesforce
              - hubspot
              - zoho_bigin
            description: |
              The channel. It cannot change after the action is created:
              delete it and add a new one. `google_sheets`, `slack`,
              `salesforce`, `hubspot` and `zoho_bigin` deliver through an
              account connected in the dashboard: pass its id as
              `integration_id` (see List integrations).
          integration_id:
            type: integer
            description: |
              `google_sheets`, `slack`, `salesforce`, `hubspot`, `zoho_bigin`
              only, required: the id of your integration of that type.
          spreadsheet_id:
            type: string
            description: |
              `google_sheets` only, required: the id in the sheet's URL, the
              part after `/d/`.
            example: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms
          spreadsheet_name:
            type: string
            description: '`google_sheets` only: the sheet''s name, for display.'
          worksheet_name:
            type: string
            description: '`google_sheets` only: the tab to append to. Defaults to `Sheet1`.'
            example: Calls
          channel_id:
            type: string
            description: '`slack` only: the channel id. Send this or `channel_name`.'
            example: C08RTQ1NY81
          channel_name:
            type: string
            description: '`slack` only: the channel name. Send this or `channel_id`.'
            example: sales
          object_name:
            type: string
            description: |
              `salesforce`: `Lead` (default), `Contact`, `Account`,
              `Opportunity`, `Case`, `Task` or `Product`. `hubspot`, required:
              `contact`, `company`, `deal` or `ticket`. Both send a fixed set of
              fields for the chosen object, so they take no `extracted_variables`.
          create_call_log:
            type: boolean
            description: '`zoho_bigin` only: log the call in Zoho Bigin. Defaults to true.'
          update_contact:
            type: boolean
            description: >-
              `zoho_bigin` only: update a matching contact with what the call captured. Defaults to
              true.
          create_contact:
            type: boolean
            description: '`zoho_bigin` only: create a contact when no contact matches. Defaults to true.'
          recipients:
            type: array
            description: '`email` only, required: the addresses to notify.'
            items:
              type: string
              format: email
            example:
              - support@acme-corp.io
          url:
            type: string
            format: uri
            description: '`webhook` only, required: the endpoint that receives a POST with the call payload.'
            example: https://crm.acme-corp.io/omnidim-callback
          phone_number_id:
            type: integer
            description: >-
              `cloud_whatsapp` only, required: your Cloud WhatsApp number the message is sent from.
              Also send `template_id` or `templates`, or nothing is sent.
          template_id:
            type: integer
            description: '`cloud_whatsapp` only: an approved template on that number.'
          template_variables:
            type: array
            description: '`cloud_whatsapp` only: which extracted variable fills each template placeholder.'
            items:
              type: object
              properties:
                index:
                  type: string
                  description: The placeholder number, as a string.
                  example: '1'
                extracted_var:
                  type: string
                  description: The key of the extracted variable whose value fills this placeholder.
                  example: customer_name
          templates:
            type: array
            description: '`cloud_whatsapp` only: one or more templates to send.'
            items:
              type: object
              description: One Cloud WhatsApp template to send after the call.
              properties:
                template_id:
                  type: integer
                  description: An approved template on the chosen number.
                usage_description:
                  type: string
                  description: |
                    When this template should be sent. After the call, the model reads
                    these descriptions to choose which templates fit the conversation.
                  example: Send when the caller books an appointment.
                always_send:
                  type: boolean
                  description: Send this template after every call, whichever templates the model chooses.
                variable_mappings:
                  type: array
                  description: How to fill each template placeholder.
                  items:
                    type: object
                    properties:
                      index:
                        type: string
                        description: The placeholder number, as a string.
                        example: '1'
                      extracted_var:
                        type: string
                        description: The extracted variable whose value fills this placeholder.
                      static_value:
                        type: string
                        description: |
                          A fixed value for this placeholder. When set, it is used
                          instead of the extracted variable.
                      mode:
                        type: string
                        enum:
                          - variable
                          - static
                        description: |
                          Which input the dashboard shows for this placeholder. It
                          does not change the value sent: a `static_value` is used
                          first, then the extracted variable, then `fallback_value`.
                      fallback_value:
                        type: string
                        description: The value to use when the variable is not extracted.
          workflow_id:
            type: integer
            description: >-
              `workflow` only, required: the workflow to run. It must have a published version, or
              the action is skipped.
          include:
            type: array
            description: Which sections to include.
            items:
              type: string
              enum:
                - summary
                - extracted_variables
                - fullConversation
                - sentiment
          extracted_variables:
            type: array
            description: |
              Variables the model should pull out of the conversation. A key
              already used by another action on this agent must have the same
              prompt, or the request is refused with `400`. Other actions are
              never changed to match.
            items:
              type: object
              required:
                - key
                - prompt
              properties:
                key:
                  type: string
                  description: Unique identifier for the variable in the post-call payload.
                  example: customer_issue
                prompt:
                  type: string
                  description: Instruction for the model on what to pull out of the conversation.
                  example: Identify the main issue the customer is experiencing.
          trigger_call_statuses:
            type: array
            description: |
              Call outcomes that fire this action. Omit to use the default
              (`completed`, `voicemail_detected`).
            items:
              type: string
              enum:
                - completed
                - voicemail_detected
                - failed
                - no-answer
                - busy
                - canceled
        required:
          - type
      example:
        type: webhook
        url: https://crm.acme-corp.io/omnidim-callback
        include:
          - summary
          - extracted_variables
        extracted_variables:
          - key: outcome
            prompt: Did the caller book an appointment?
        trigger_call_statuses:
          - completed
          - failed
responses:
  '201':
    description: The action was added.
    content:
      application/json:
        schema:
          type: object
          properties:
            action:
              type: object
              description: |
                One post-call action on an agent, with the fields of its type.
              properties:
                id:
                  type: integer
                  description: |
                    The action's id. Saving post-call changes in the dashboard, or
                    restoring a version, gives every action a new id. To find an
                    action you added, list the actions and match its target (`url`,
                    `recipients` or `integration_id`) instead of keeping the id.
                type:
                  type: string
                  enum:
                    - email
                    - webhook
                    - omni_crm
                    - cloud_whatsapp
                    - workflow
                    - google_sheets
                    - slack
                    - salesforce
                    - hubspot
                    - zoho_bigin
                recipients:
                  type: array
                  items:
                    type: string
                url:
                  type: string
                phone_number_id:
                  type: integer
                  nullable: true
                template_id:
                  type: integer
                  nullable: true
                template_variables:
                  type: array
                  nullable: true
                  items:
                    type: object
                templates:
                  type: array
                  nullable: true
                  items:
                    type: object
                workflow_id:
                  type: integer
                  nullable: true
                integration_id:
                  type: integer
                  nullable: true
                  description: The connected account the action delivers through.
                spreadsheet_id:
                  type: string
                  nullable: true
                spreadsheet_name:
                  type: string
                  nullable: true
                worksheet_name:
                  type: string
                  nullable: true
                channel_id:
                  type: string
                  nullable: true
                channel_name:
                  type: string
                  nullable: true
                object_name:
                  type: string
                  nullable: true
                create_call_log:
                  type: boolean
                update_contact:
                  type: boolean
                create_contact:
                  type: boolean
                include:
                  type: array
                  items:
                    type: string
                extracted_variables:
                  type: array
                  items:
                    type: object
                    required:
                      - key
                      - prompt
                    properties:
                      key:
                        type: string
                        description: Unique identifier for the variable in the post-call payload.
                        example: customer_issue
                      prompt:
                        type: string
                        description: Instruction for the model on what to pull out of the conversation.
                        example: Identify the main issue the customer is experiencing.
                trigger_call_statuses:
                  type: array
                  items:
                    type: string
            applies_after_publish:
              type: boolean
              description: |
                False for an agent that has never been published: the change is live
                on the next call. True when the agent is published: changes go to the
                draft, so they reach live calls only after you publish the agent in
                the dashboard.
  '400':
    description: The action is not valid. Nothing was added.
    content:
      application/json:
        schema:
          type: object
          properties:
            error:
              type: string
              description: Machine-readable error code.
            error_description:
              type: string
              description: What was wrong with the request.
        example:
          error: invalid_request
          error_description: 'Missing required fields: url'
  '401':
    description: Missing or invalid API key.
  '403':
    description: The API key's user cannot make changes to agents.
    content:
      application/json:
        schema:
          type: object
          properties:
            error:
              type: string
              description: Machine-readable error code.
            error_description:
              type: string
              description: What was wrong with the request.
        example:
          error: forbidden
          error_description: You do not have permission to make changes to Voice AI Assistants.
  '404':
    description: Agent not found or access denied.
  '409':
    description: |
      The `Idempotency-Key` was already used with a different request.
    content:
      application/json:
        schema:
          type: object
          properties:
            error:
              type: string
              description: Machine-readable error code.
            error_description:
              type: string
              description: What was wrong with the request.
        example:
          error: conflict
          error_description: >-
            This Idempotency-Key was already used with a different request. Use a new key for a new
            request.
```

**curl**

```bash
curl -X POST "https://backend.omnidim.io/api/v1/agents/{agent_id}/post-call-actions" \
  -H "Authorization: Bearer $OMNIDIM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "webhook",
  "url": "https://crm.acme-corp.io/omnidim-callback",
  "include": [
    "summary",
    "extracted_variables"
  ],
  "extracted_variables": [
    {
      "key": "outcome",
      "prompt": "Did the caller book an appointment?"
    }
  ],
  "trigger_call_statuses": [
    "completed",
    "failed"
  ]
}'
```