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

# Fetch Call Outcomes, Transcripts, and Cost Data via API

> Retrieve the result, full transcript, duration, and cost of any Scalysis call using the order ID returned when the call was triggered.

Once an AI-powered call finishes, Scalysis stores the full outcome — including a structured transcript, call result, duration, and cost — and makes it available through the orders outcome endpoint. You can use this data to automate downstream workflows, populate your CRM, flag orders that need human follow-up, or simply audit what was said on every call.

## When to fetch

The outcome endpoint is only meaningful **after the call ends**. If you query it while the call is still active, the response will reflect an `in_progress` status with no transcript yet. Wait until the call has had time to complete — typically 30 seconds to a few minutes — and then fetch. If you get an `in_progress` response, wait 10–30 seconds and retry.

***

<Steps>
  <Step title="Get the order_id">
    The `order_id` is returned in the response body every time you [trigger a call](/guides/trigger-a-call). It looks like this:

    ```json theme={null}
    {
      "success": true,
      "action": "trigger_call",
      "order_id": 1368642,
      "script_id": 2207,
      "call_status": "in_progress",
      "message": "Call started"
    }
    ```

    Make sure you persist the `order_id` in your system at the time of triggering. It is the only way to look up a specific call's outcome after the fact.

    <Note>
      For calls placed through a campaign, each contact's `order_id` is accessible via the campaign reporting views in your dashboard, or through future campaign contacts API endpoints.
    </Note>
  </Step>

  <Step title="Send the GET request">
    Replace `1368642` in the path with your actual `order_id`, and swap in your real API key:

    ```bash theme={null}
    curl -sS 'https://app.scalysis.com/api/v1/orders/1368642/outcome' \
      -H 'Authorization: Bearer YOUR_API_KEY'
    ```

    No request body is needed — this is a plain authenticated GET request.
  </Step>

  <Step title="Read the response">
    A completed call returns a response like this:

    ```json theme={null}
    {
      "success": true,
      "orderId": 1368642,
      "orderNumber": "ORD-1001",
      "callStatus": "completed",
      "callDurationSec": 87,
      "callOutcome": "confirmed",
      "totalCallCost": 0.043,
      "summary": "The customer confirmed the order and agreed to receive the delivery on Friday between 10am and 1pm.",
      "transcript": [
        {
          "speaker": "agent",
          "text": "Hello, am I speaking with Rahul?",
          "timestamp": "0:03"
        },
        {
          "speaker": "customer",
          "text": "Yes, speaking.",
          "timestamp": "0:06"
        },
        {
          "speaker": "agent",
          "text": "Hi Rahul, I'm calling from Scalysis regarding your order ORD-1001. Can you confirm you'd like to proceed with the delivery?",
          "timestamp": "0:08"
        },
        {
          "speaker": "customer",
          "text": "Yes, please go ahead.",
          "timestamp": "0:19"
        },
        {
          "speaker": "system",
          "text": "Call ended — outcome recorded as confirmed.",
          "timestamp": "1:27"
        }
      ]
    }
    ```

    **Field reference:**

    | Field             | Type    | Description                                                                                                                                           |
    | ----------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `success`         | boolean | `true` when the request succeeded and data is available.                                                                                              |
    | `orderId`         | number  | Echo of the order ID you queried.                                                                                                                     |
    | `orderNumber`     | string  | Your original order reference (e.g. `ORD-1001`), if you provided one.                                                                                 |
    | `callStatus`      | string  | Final status of the call: `completed`, `in_progress`, `failed`, `no_answer`, etc.                                                                     |
    | `callDurationSec` | number  | Total call length in seconds.                                                                                                                         |
    | `callOutcome`     | string  | AI-determined result of the call, e.g. `"confirmed"`, `"cancelled"`, `"callback_requested"`. The possible values depend on your script configuration. |
    | `totalCallCost`   | number  | Cost of the call in your account's billing currency.                                                                                                  |
    | `summary`         | string  | A concise natural-language summary of what was discussed and agreed on the call.                                                                      |
    | `transcript`      | array   | Ordered list of utterances from the conversation — see below.                                                                                         |

    <Note>
      Recording audio URLs are not included in the outcome response. The full conversation is represented through the structured `transcript` array and the `summary` field.
    </Note>

    ### Understanding the transcript array

    Each item in `transcript` represents a single utterance and has three fields:

    | Field       | Description                                                                                                   |
    | ----------- | ------------------------------------------------------------------------------------------------------------- |
    | `speaker`   | Who spoke: `"agent"` (the AI), `"customer"`, or `"system"` (automated events such as call start/end markers). |
    | `text`      | The transcribed text of the utterance.                                                                        |
    | `timestamp` | Time offset from the start of the call in `M:SS` format.                                                      |

    <Tip>
      The `callOutcome` field is ideal for driving automated downstream logic. For example, you can route `"confirmed"` orders straight to your fulfillment pipeline, flag `"cancelled"` orders for a refund flow, and send `"callback_requested"` outcomes to your human agent queue — all without any manual review.
    </Tip>
  </Step>

  <Step title="Handle in-progress calls">
    If the call hasn't finished yet, the response will look like this:

    ```json theme={null}
    {
      "success": true,
      "orderId": 1368642,
      "callStatus": "in_progress",
      "summary": null,
      "transcript": []
    }
    ```

    When you see `"callStatus": "in_progress"` (or an empty transcript), **do not treat this as a final result**. Instead:

    1. Wait **10–30 seconds**.
    2. Retry the same GET request.
    3. Repeat until `callStatus` changes to a terminal state (e.g. `completed`, `no_answer`, `failed`).

    <Warning>
      Avoid polling more frequently than once every 10 seconds. Excessive polling can trigger rate limits on your API key.
    </Warning>
  </Step>
</Steps>
