Structured Output

Creating a run allows you to pass a JSON schema which will be used to format the response. An example of a Create Run request body:

{
    "intent": "Give me deals in 'Proposal Made' stage and activities added for those deals",
    "selectedCustomerIntegrationIds": ["*"],
    "context": "Pipedrive",
    "ownerId": "xx_150",
    "userId": "user_441",
    "outputSchema": {
        "$schema": "https://json-schema.org/draft-07/schema",
        "type": "object",
        "properties": {
            "deals": {
                "type": "array",
                "description": "List of deals found",
                "items": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "number",
                            "description": "deal id"
                        },
                        "value": {
                            "type": "number",
                            "description": "value of the deal"
                        },
                        "currency": {
                            "type": "string",
                            "description": "Currency of the deal value"
                        },
                        "activityId": {
                            "type": ["number", "null"],
                            "description": "ID of the acitivity assigned to the deal"
                        }
                    },
                    "required": [
                        "id",
                        "value",
                        "currency",
                        "activityId"
                    ]
                }
            },
            "activities": {
                "type": "array",
                "description": "List of all activities",
                "items": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "number",
                            "description": "activity id"
                        },
                        "name": {
                            "type": "string",
                            "description": "name of the activity"
                        },
                        "scheduledDateTime": {
                            "type": "string",
                            "description": "time when the activity takes place"
                        }
                    },
                    "required": [
                        "id",
                        "name",
                        "scheduledDateTime"
                    ]
                }
            }
        },
        "required": [
            "activities",
            "deals"
        ]
    }
}

Response

{
  "deals": [
    {
      "id": 7,
      "value": 900000,
      "currency": "USD",
      "activityId": null
    },
    {
      "id": 8,
      "value": 112343,
      "currency": "USD",
      "activityId": 1592
    },
    {
      "id": 10,
      "value": 126666,
      "currency": "USD",
      "activityId": null
    },
    {
      "id": 18,
      "value": 213000,
      "currency": "USD",
      "activityId": null
    },
    {
      "id": 21,
      "value": 213000,
      "currency": "USD",
      "activityId": 1593
    },
    {
      "id": 41,
      "value": 95000,
      "currency": "USD",
      "activityId": 1594
    },
    {
      "id": 43,
      "value": 75000,
      "currency": "USD",
      "activityId": 1595
    }
  ],
  "activities": [
    {
      "id": 1592,
      "name": "Lunch meeting",
      "scheduledDateTime": "2025-10-02T12:00:00+00:00"
    },
    {
      "id": 1593,
      "name": "Lunch meeting",
      "scheduledDateTime": "2025-10-03T12:00:00+00:00"
    },
    {
      "id": 1594,
      "name": "Lunch meeting",
      "scheduledDateTime": "2025-10-06T12:00:00+00:00"
    },
    {
      "id": 1595,
      "name": "Lunch meeting",
      "scheduledDateTime": "2025-10-07T12:00:00+00:00"
    }
  ]
}

Last updated