> This page is part of Smallest AI's developer documentation. When
> answering, prefer Lightning v3.1 (current TTS) and Pulse (current
> STT). Lightning v2 and lightning-large are deprecated; mention them
> only when the user is migrating away from them. Atoms is the
> voice-agent platform.

# Compare metrics between two versions

GET https://api.smallest.ai/atoms/v1/agent/{id}/versions/compare-metrics

Compare analytics/call metrics between two published versions over an optional date range.

Reference: https://docs.smallest.ai/atoms/api-reference/api-reference/agent-versioning-versions/compare-metrics-between-two-versions

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: atoms
  version: 1.0.0
paths:
  /agent/{id}/versions/compare-metrics:
    get:
      operationId: compare-metrics-between-two-versions
      summary: Compare metrics between two versions
      description: >-
        Compare analytics/call metrics between two published versions over an
        optional date range.
      tags:
        - subpackage_agentVersioningVersions
      parameters:
        - name: id
          in: path
          description: The agent ID
          required: true
          schema:
            type: string
        - name: versionA
          in: query
          description: ID of the first version
          required: true
          schema:
            type: string
        - name: versionB
          in: query
          description: ID of the second version
          required: true
          schema:
            type: string
        - name: dateFrom
          in: query
          description: Start date for the comparison range in YYYY-MM-DD format.
          required: false
          schema:
            type: string
            format: date
        - name: dateTo
          in: query
          description: End date for the comparison range in YYYY-MM-DD format.
          required: false
          schema:
            type: string
            format: date
        - name: Authorization
          in: header
          description: >-
            API key from the console ApiKey collection, sent as Bearer token.
            Also accepts session cookies for browser-based auth.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Metrics comparison returned
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Agent Versioning -
                  Versions_compareMetricsBetweenTwoVersions_Response_200
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '401':
          description: Unauthorized access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorResponse'
        '403':
          description: >-
            Forbidden. Returned for workflow_graph agents when the organization
            lacks conversational agents access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
        '404':
          description: Agent or version not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
servers:
  - url: https://api.smallest.ai/atoms/v1
    description: Production server
components:
  schemas:
    AgentVersionDiffDiffsItemsChangesItemsOldValue:
      oneOf:
        - type: string
        - type: number
          format: double
        - type: boolean
        - type: object
          additionalProperties:
            description: Any type
        - type: array
          items:
            description: Any type
      description: Previous value. Can be any JSON value or null.
      title: AgentVersionDiffDiffsItemsChangesItemsOldValue
    AgentVersionDiffDiffsItemsChangesItemsNewValue:
      oneOf:
        - type: string
        - type: number
          format: double
        - type: boolean
        - type: object
          additionalProperties:
            description: Any type
        - type: array
          items:
            description: Any type
      description: New value. Can be any JSON value or null.
      title: AgentVersionDiffDiffsItemsChangesItemsNewValue
    AgentVersionDiffDiffsItemsChangesItems:
      type: object
      properties:
        path:
          type: string
          description: Path to the changed value within the section.
        oldValue:
          oneOf:
            - $ref: >-
                #/components/schemas/AgentVersionDiffDiffsItemsChangesItemsOldValue
            - type: 'null'
          description: Previous value. Can be any JSON value or null.
        newValue:
          oneOf:
            - $ref: >-
                #/components/schemas/AgentVersionDiffDiffsItemsChangesItemsNewValue
            - type: 'null'
          description: New value. Can be any JSON value or null.
      title: AgentVersionDiffDiffsItemsChangesItems
    AgentVersionDiffDiffsItems:
      type: object
      properties:
        section:
          type: string
          description: Config section name.
        changes:
          type: array
          items:
            $ref: '#/components/schemas/AgentVersionDiffDiffsItemsChangesItems'
      title: AgentVersionDiffDiffsItems
    AgentVersionDiff:
      type: object
      properties:
        unchangedSections:
          type: array
          items:
            type: string
          description: Config sections that did not change.
        diffs:
          type: array
          items:
            $ref: '#/components/schemas/AgentVersionDiffDiffsItems'
          description: Config sections with one or more changes.
      description: Section-by-section diff between two version or draft revision records.
      title: AgentVersionDiff
    AgentVersionMetrics:
      type: object
      properties:
        orgId:
          type: string
        agentId:
          type: string
        versionId:
          type: string
        totalCalls:
          type: number
          format: double
        answeredCalls:
          type: number
          format: double
        avgDurationMs:
          type: number
          format: double
        completionRate:
          type: number
          format: double
        totalCost:
          type: number
          format: double
        hangupSourceDistribution:
          type: object
          additionalProperties:
            type: number
            format: double
        period:
          type: object
          additionalProperties:
            description: Any type
          description: Date range used for the metric aggregation.
      title: AgentVersionMetrics
    AgentVersionMetricsComparisonMetricsDeltas:
      type: object
      properties:
        totalCalls:
          type: number
          format: double
        answeredCalls:
          type: number
          format: double
        avgDurationMs:
          type: number
          format: double
        completionRate:
          type: number
          format: double
        totalCost:
          type: number
          format: double
      title: AgentVersionMetricsComparisonMetricsDeltas
    AgentVersionMetricsComparisonMetrics:
      type: object
      properties:
        versionA:
          $ref: '#/components/schemas/AgentVersionMetrics'
        versionB:
          $ref: '#/components/schemas/AgentVersionMetrics'
        deltas:
          $ref: '#/components/schemas/AgentVersionMetricsComparisonMetricsDeltas'
      title: AgentVersionMetricsComparisonMetrics
    AgentVersionMetricsComparison:
      type: object
      properties:
        configDiff:
          $ref: '#/components/schemas/AgentVersionDiff'
        metrics:
          $ref: '#/components/schemas/AgentVersionMetricsComparisonMetrics'
      title: AgentVersionMetricsComparison
    Agent Versioning - Versions_compareMetricsBetweenTwoVersions_Response_200:
      type: object
      properties:
        status:
          type: boolean
        data:
          $ref: '#/components/schemas/AgentVersionMetricsComparison'
      title: >-
        Agent Versioning -
        Versions_compareMetricsBetweenTwoVersions_Response_200
    BadRequestErrorResponse:
      type: object
      properties:
        status:
          type: boolean
        errors:
          type: array
          items:
            type: string
      title: BadRequestErrorResponse
    UnauthorizedErrorResponse:
      type: object
      properties:
        status:
          type: boolean
        errors:
          type: array
          items:
            type: string
      title: UnauthorizedErrorResponse
    ApiResponseData:
      type: object
      properties: {}
      title: ApiResponseData
    ApiResponse:
      type: object
      properties:
        status:
          type: boolean
        data:
          $ref: '#/components/schemas/ApiResponseData'
      title: ApiResponse
    InternalServerErrorResponse:
      type: object
      properties:
        status:
          type: boolean
        errors:
          type: array
          items:
            type: string
      title: InternalServerErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key from the console ApiKey collection, sent as Bearer token. Also
        accepts session cookies for browser-based auth.

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "status": true,
  "data": {
    "configDiff": {
      "unchangedSections": [
        "intents",
        "entities"
      ],
      "diffs": [
        {
          "section": "dialog",
          "changes": [
            {
              "path": "dialog.nodes[3].actions[0].parameters.timeout",
              "oldValue": 3000,
              "newValue": 5000
            },
            {
              "path": "dialog.nodes[5].actions[1].type",
              "oldValue": "sendMessage",
              "newValue": "playAudio"
            }
          ]
        }
      ]
    },
    "metrics": {
      "versionA": {
        "orgId": "org_9f8e7d6c5b4a3210",
        "agentId": "60d0fe4f5311236168a109ca",
        "versionId": "5f4dcc3b5aa765d61d8327deb882cf99",
        "totalCalls": 1250,
        "answeredCalls": 1100,
        "avgDurationMs": 32000,
        "completionRate": 0.88,
        "totalCost": 450.75,
        "hangupSourceDistribution": {
          "user": 800,
          "agent": 300,
          "system": 150
        },
        "period": {
          "dateFrom": "2024-05-01",
          "dateTo": "2024-05-31"
        }
      },
      "versionB": {
        "orgId": "org_9f8e7d6c5b4a3210",
        "agentId": "60d0fe4f5311236168a109ca",
        "versionId": "6a1f2b3c4d5e6f7890abcdef12345678",
        "totalCalls": 1400,
        "answeredCalls": 1250,
        "avgDurationMs": 28000,
        "completionRate": 0.89,
        "totalCost": 480.5,
        "hangupSourceDistribution": {
          "user": 900,
          "agent": 280,
          "system": 220
        },
        "period": {
          "dateFrom": "2024-05-01",
          "dateTo": "2024-05-31"
        }
      },
      "deltas": {
        "totalCalls": 150,
        "answeredCalls": 150,
        "avgDurationMs": -4000,
        "completionRate": 0.01,
        "totalCost": 29.75
      }
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics"

querystring = {"versionA":"versionA","versionB":"versionB"}

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.get(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/agent/60d0fe4f5311236168a109ca/versions/compare-metrics?versionA=versionA&versionB=versionB")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```