> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.twelvelabs.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server.

# Retrieve analysis task status and results

GET https://api.twelvelabs.io/v1.3/analyze/tasks/{task_id}

This method retrieves the status and results of an analysis task.

**Task statuses**:
- `queued`: The task is waiting to be processed.
- `pending`: The task is queued and waiting to start.
- `processing`: The platform is analyzing the video.
- `ready`: Processing is complete. Results are available in the response.
- `failed`: The task failed. No result is available. The `error` field describes the failure.
- `canceled`: The task was canceled. No result is available. The `error` field describes the cancellation reason, if available.

Poll this method until `status` is `ready`, `failed`, or `canceled`. When `status` is `ready`, use the results from the response.


Reference: https://docs.twelvelabs.io/api-reference/analyze-videos/retrieve-analysis-task-status-results

## Authentication

- `x-api-key` header (required) — Your API key. You can find your API key on the API Keys page.

## Request

### Path parameters

- `task_id` (string, required) — The unique identifier of the analysis task.

## Response

### 200

Task status and results retrieved successfully

- `task_id` (string, required) — The unique identifier of the analysis task.
- `custom_id` (string, required, nullable) — The identifier you provided in the `custom_id` field when you created the task, or `null` if you did not set one. This key is always present in the response.
- `status` (enum, required) — The current status of the analysis task. The `ready`, `failed`, and `canceled` statuses are final.
  - Allowed values: `queued`, `pending`, `processing`, `ready`, `failed`, `canceled`
- `created_at` (string, required) — A string representing the date and time, in RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the analysis task was created.
- `batch_id` (string, optional) — The unique identifier of the batch that the task was created in. The platform returns this field only for tasks created as part of a batch.
- `video_source` (AnalyzeTaskResponseVideoSource, optional, nullable) — The public video source associated with the task. When the video was uploaded using the [`POST`](/v1.3/api-reference/index-content/create) method of the `/tasks` endpoint, the source type is `video_id`. Otherwise, the source type is `url`, `base64_string`, or `asset_id`.
- `request_params` (AnalyzeTaskResponseRequestParams, optional, nullable) — The request parameters for this task.
- `completed_at` (string, optional) — A string representing the date and time, in RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the analysis task completed, failed, or was canceled. The platform returns this field only if `status` is `ready`, `failed`, or `canceled`.
- `result` (AnalyzeTaskResult, optional) — An object that contains the generated text and additional information. The platform returns this object only when `status` is `ready`. When the task fails or is canceled, the response contains no `result` object, so `generation_id` and `usage` are absent.
- `error` (AnalyzeTaskError, optional) — A message attached to the task response. The platform sets this field in the following cases: - **Task failure**: `status` is `failed`. The `message` field describes the failure reason. With video segmentation, a task can fail because the analysis reached the maximum response length or the context window before it could complete. The response contains no `result` object. - **Task cancellation**: `status` is `canceled` and a cancellation reason is available. A task newly canceled through the task cancellation endpoint has `code` set to `user_canceled`; canceling the task again does not change the reason. - **Truncation warning** (general analysis): `status` is `ready` and `result.finish_reason` is `length`. The `message` field describes the truncation cause (either the maximum response length was reached or the context window was reached). The partial output is in `result.data`. Not set when `status` is `ready` and `result.finish_reason` is `stop`. A canceled task can omit this field when no cancellation reason is available.
- `webhooks` (list of AnalyzeTaskWebhookInfo, optional) — The delivery status of each webhook endpoint. The platform omits this field when no webhooks are configured. You can register webhooks through the Playground. See the [Webhooks](/v1.3/docs/advanced/webhooks) page for details.

## Errors

### 404 Not Found Error

Task not found

- `error` (ErrorResponseError, required)

## Types

### AnalyzeTaskResponseVideoSource

The public video source associated with the task. When the video was uploaded using the [`POST`](/v1.3/api-reference/index-content/create) method of the `/tasks` endpoint, the source type is `video_id`. Otherwise, the source type is `url`, `base64_string`, or `asset_id`.

- `type` (enum, optional) — The type of video source.
  - Allowed values: `url`, `base64_string`, `asset_id`, `video_id`
- `url` (string, optional, nullable) — The video URL. Present when `type` is `url`.
- `asset_id` (string, optional, nullable) — The asset ID. Present when `type` is `asset_id`.
- `system_metadata` (AnalyzeTaskResponseVideoSourceSystemMetadata, optional, nullable) — Video metadata that the platform extracted during processing, such as its duration. Present on a best-effort basis once the video has been processed.
- `video_id` (string, optional, nullable, deprecated) — The video identifier. Present when `type` is `video_id`.
- `index_id` (string, optional, nullable, deprecated) — The identifier of the index associated with the video. Present on a best-effort basis when `type` is `video_id`.

### AnalyzeTaskResponseRequestParams

The request parameters for this task.

- `analysis_mode` (enum, optional) — The analysis approach for this task.
  - Allowed values: `general`, `time_based_metadata`
- `prompt` (string, optional, nullable) — The natural-language prompt for this task. Present only when `analysis_mode` is `general` and the task was created with `prompt` (not `prompt_v2`). - [List](/v1.3/api-reference/analyze-videos/list-async-analysis-tasks): Truncated to the first 30 characters. - [Retrieve](/v1.3/api-reference/analyze-videos/retrieve-analysis-task-status-results): Returns the full text.
- `prompt_v2` (AnalyzeTaskResponseRequestParamsPromptV2, optional, nullable) — The structured prompt for this task. Present only when `analysis_mode` is `general` and the task was created with `prompt_v2`. When present, the response excludes the `prompt` field. - [List](/v1.3/api-reference/analyze-videos/list-async-analysis-tasks): `input_text` is truncated to the first 30 characters. - [Retrieve](/v1.3/api-reference/analyze-videos/retrieve-analysis-task-status-results): Returns the full text.
- `response_format` (AnalyzeTaskResponseRequestParamsResponseFormat, optional, nullable) — The response format for this task. Present only when the request included a response format.
- `temperature` (double, optional, nullable) — The temperature value for this analysis.
- `max_tokens` (integer, optional, nullable) — The maximum response length you set, in tokens.
- `min_segment_duration` (double, optional, nullable) — The minimum segment duration you set, in seconds. Present when `analysis_mode` is `time_based_metadata`.
- `max_segment_duration` (double, optional, nullable) — The maximum segment duration you set, in seconds. Present when `analysis_mode` is `time_based_metadata`.
- `start_time` (double, optional, nullable) — The start of the analysis window, in seconds. Present only when the task was created with `start_time`.
- `end_time` (double, optional, nullable) — The end of the analysis window, in seconds. Present only when the task was created with `end_time`.

### AnalyzeTaskResult

The analysis results for a completed task.

- `generation_id` (string, required) — The unique identifier for the generation session.
- `data` (string, required) — The generated text for this analysis task. The format depends on the `analysis_mode` used when creating the task: - **When `analysis_mode` is not set**: A plain-text string containing the generated text based on the prompt you provided. - **When `analysis_mode` is `time_based_metadata`**: A JSON-encoded string containing an object keyed by segment definition (the `id` field). Each key maps to an array of segment objects with the following fields: - `start_time` (number): The start time of the segment in seconds. - `end_time` (number): The end time of the segment in seconds. - `metadata` (object): The custom fields you defined in the request's `segment_definitions[].fields`.
- `finish_reason` (enum, required) — When the task uses general analysis, `length` means the response reached the maximum response length or the context window. The partial output is in `data`, and a warning is in the task's `error` field. With video segmentation, if the analysis reaches either limit, the task fails and `length` never occurs.
  - Allowed values: `stop`, `length`
- `usage` (AnalyzeTaskResultUsage, required) — The number of tokens used in the generation.

### AnalyzeTaskError

A message attached to an analysis response. The platform uses this object in the following cases: - **Task failure** — when `status` is `failed`. The `message` field describes the failure. - **Task cancellation** — when `status` is `canceled` and a cancellation reason is available. - **Truncation warning (general analysis)** — set on the response `error` when `finish_reason` is `length`, because either `output_tokens` reached the requested `max_tokens` value or the input and response reached the [context window](/v1.3/docs/concepts/models/pegasus#context-window). To obtain the full output, increase the `max_tokens` value or reduce the input size. The partial output is in `result.data` for asynchronous analysis and in `data` for synchronous analysis. - With general analysis, check `finish_reason` instead of parsing the message text. With video segmentation, check `status`.

- `message` (string, required) — A human-readable message. One of: - **Other failures** (async, `status: failed`): the message describes the failure reason. Example: `"Video duration exceeds maximum allowed duration"`. - **Failure: maximum response length reached** (`time_based_metadata`, `status: failed`): `"analysis failed: the time_based_metadata output reached the configured max_tokens before a complete result was produced. Raise max_tokens if it is below the per-model maximum; otherwise narrow the request (fewer segment_definitions or fields, a larger min_segment_duration, or a shorter analysis window)."`. - **Failure: context window reached** (`time_based_metadata`, `status: failed`): `"analysis failed: the time_based_metadata output reached the model's context limit (combined input and output tokens) before a complete result was produced. Narrow the request (fewer segment_definitions or fields, a larger min_segment_duration, a shorter analysis window, fewer media bindings) or lower max_tokens to leave more room for the input."`. - **Cancellation** (async, `status: canceled`): explains why the task was canceled. Example: `"The task was canceled by the user."`. - **Truncation: maximum response length reached** (`general`, `finish_reason: length`, `output_tokens >= max_tokens`): `"output truncated: the generation reached the configured max_tokens. The partial output is returned; raise max_tokens if you need a longer response."`. - **Truncation: context window reached** (`general`, `finish_reason: length`, model stopped before reaching `max_tokens`): `"output truncated: combined input and output tokens reached the model's context limit. The partial output is returned; consider reducing input size (shorter prompt, smaller video clip, fewer media bindings) or lowering max_tokens."`. The exact text is not part of the contract. Do not parse it.
- `code` (string, optional) — A machine-readable code that identifies the task's condition. Values include: - `user_canceled`: A task was canceled through the task cancellation endpoint. - `batch_canceled`: A queued task was canceled because its batch was canceled. - `batch_expired`: A queued task was canceled because its batch expired. - `batch_processing_timeout`: A processing batch task failed after reaching the batch processing deadline. These task condition codes are distinct from API error response codes, even when a string appears in both. The platform can return other values. Clients must tolerate unrecognized values and must not parse `message` as a discriminator. The platform omits this field for failures and truncation warnings that have no code.

### AnalyzeTaskWebhookInfo

The delivery status of a webhook endpoint.

- `url` (string, required) — The URL of the webhook endpoint that received the delivery.
- `delivered` (boolean, required) — Indicates whether the platform successfully delivered the webhook.
- `attempts` (integer, required) — The total number of delivery attempts for this URL.
- `last_error` (string, optional) — The error message from the last failed delivery attempt. This field appears only when `delivered` is `false`.

### ErrorResponseError

- `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface.
- `details` (map from string to any, optional) — Additional error details (optional)

### AnalyzeTaskResponseVideoSourceSystemMetadata

Video metadata that the platform extracted during processing, such as its duration. Present on a best-effort basis once the video has been processed.

- `duration` (double, optional) — The video duration in seconds.

### AnalyzeTaskResponseRequestParamsPromptV2

The structured prompt for this task. Present only when `analysis_mode` is `general` and the task was created with `prompt_v2`. When present, the response excludes the `prompt` field. - [List](/v1.3/api-reference/analyze-videos/list-async-analysis-tasks): `input_text` is truncated to the first 30 characters. - [Retrieve](/v1.3/api-reference/analyze-videos/retrieve-analysis-task-status-results): Returns the full text.

- `input_text` (string, optional) — The prompt text. May contain `<@name>` placeholders that reference entries in `media_sources`.
- `media_sources` (list of AnalyzeTaskResponseRequestParamsPromptV2MediaSourcesItems, optional) — Reference images linked to `<@name>` placeholders in the prompt.

### AnalyzeTaskResponseRequestParamsResponseFormat

The response format for this task. Present only when the request included a response format.

- `type` (enum, optional)
  - Allowed values: `json_schema`, `segment_definitions`
- `json_schema` (AnalyzeTaskResponseRequestParamsResponseFormatJsonSchema, optional, nullable) — The JSON schema for this task. Present only when `type` is `json_schema`. - [List](/v1.3/api-reference/analyze-videos/list-async-analysis-tasks): Omitted. - [Retrieve](/v1.3/api-reference/analyze-videos/retrieve-analysis-task-status-results): Returns the full schema.
- `segment_definitions` (list of AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItems, optional) — The segment definitions for this task. Present only when `type` is `segment_definitions`. - [List](/v1.3/api-reference/analyze-videos/list-async-analysis-tasks): Returns only the first element. - [Retrieve](/v1.3/api-reference/analyze-videos/retrieve-analysis-task-status-results): Returns the full array.

### AnalyzeTaskResultUsage

The number of tokens used in the generation.

- `output_tokens` (integer, required) — The number of tokens in the generated text.
- `input_tokens` (integer, optional) — The number of tokens the input consumed. Together with `output_tokens`, this value must fit within the [context window](/v1.3/docs/concepts/models/pegasus#context-window).

### AnalyzeTaskResponseRequestParamsPromptV2MediaSourcesItems

- `name` (string, required)
- `media_type` (string, required)
- `url` (string, optional) — Present when the source was provided as a URL.
- `asset_id` (string, optional) — Present when the source was provided as an asset identifier.

### AnalyzeTaskResponseRequestParamsResponseFormatJsonSchema

The JSON schema for this task. Present only when `type` is `json_schema`. - [List](/v1.3/api-reference/analyze-videos/list-async-analysis-tasks): Omitted. - [Retrieve](/v1.3/api-reference/analyze-videos/retrieve-analysis-task-status-results): Returns the full schema.

### AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItems

- `id` (string, required)
- `description` (string, required)
- `fields` (list of AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItemsFieldsItems, optional)
- `media_sources` (list of AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItemsMediaSourcesItems, optional)
- `time_ranges` (list of AnalyzeTimeRange, optional) — The time ranges for this segment definition. Present only when the task was created with `time_ranges`.

### AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItemsFieldsItems

- `name` (string, required)
- `type` (string, required)
- `description` (string, optional)
- `enum` (list of string, optional)
- `items` (AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItemsFieldsItemsItems, optional)

### AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItemsMediaSourcesItems

- `name` (string, required)
- `media_type` (string, required)
- `url` (string, optional)
- `asset_id` (string, optional)

### AnalyzeTimeRange

A time window within the video, expressed in seconds.

- `start_time` (double, required) — The start of the window, as an absolute timestamp in seconds, based on the internal metadata of the video. Must be less than `end_time` and within the video duration. Most videos start at 0, but some (for example, from cameras or broadcast recordings) may have a non-zero start time. To find the value, run `ffprobe -v error -show_entries format=start_time,duration -of default=noprint_wrappers=1 your_video.mp4`.
- `end_time` (double, required) — The end of the window, as an absolute timestamp in seconds, based on the internal metadata of the video. Must be greater than `start_time` by at least 2 seconds and within the video duration. Most videos start at 0, but some (for example, from cameras or broadcast recordings) may have a non-zero start time. To find the value, run `ffprobe -v error -show_entries format=start_time,duration -of default=noprint_wrappers=1 your_video.mp4`.

### AnalyzeTaskResponseRequestParamsResponseFormatSegmentDefinitionsItemsFieldsItemsItems

- `type` (string, optional)

## Examples

### Task queued

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d12",
  "custom_id": null,
  "status": "queued",
  "created_at": "2024-09-26T10:29:19.968Z"
}
```

**SDK Code**

```python Task queued
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task queued
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task queued
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

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

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task queued
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task queued
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task still pending

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d12",
  "custom_id": null,
  "status": "pending",
  "created_at": "2024-09-26T10:29:19.968Z"
}
```

**SDK Code**

```python Task still pending
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task still pending
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task still pending
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task still pending
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task still pending
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task still pending
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task still pending
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task processing

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d12",
  "custom_id": "prod-segment-analysis-42",
  "status": "processing",
  "created_at": "2024-09-26T10:29:19.968Z"
}
```

**SDK Code**

```python Task processing
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task processing
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task processing
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

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

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task processing
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task processing
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with results

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d12",
  "custom_id": "prod-segment-analysis-42",
  "status": "ready",
  "created_at": "2024-09-26T10:29:19.968Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/video.mp4",
    "system_metadata": {
      "duration": 120.5
    }
  },
  "request_params": {
    "analysis_mode": "general",
    "prompt": "Generate a detailed summary of this video in 3-4 sentences",
    "temperature": 0.2,
    "max_tokens": 4096
  },
  "completed_at": "2024-09-26T10:30:45.123Z",
  "result": {
    "generation_id": "3441e219-4413-4bc3-81c1-3bf81ce79560",
    "data": "Video Summary: A comprehensive analysis of the video content...",
    "finish_reason": "stop",
    "usage": {
      "output_tokens": 250,
      "input_tokens": 45
    }
  },
  "webhooks": [
    {
      "url": "https://example.com/callback",
      "delivered": true,
      "attempts": 3
    }
  ]
}
```

**SDK Code**

```python Task ready with results
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with results
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with results
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with results
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with results
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with results
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with results
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with results
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with structured JSON results

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d12",
  "custom_id": "prod-segment-analysis-42",
  "status": "ready",
  "created_at": "2026-04-13T10:13:23Z",
  "video_source": {
    "type": "asset_id",
    "asset_id": "698ae3f3f4a786d35a6303e1",
    "system_metadata": {
      "duration": 120.5
    }
  },
  "request_params": {
    "analysis_mode": "general",
    "prompt": "Extract the main topics and sentiment from this video.",
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "type": "object",
        "properties": {
          "topics": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sentiment": {
            "type": "string",
            "enum": [
              "positive",
              "negative",
              "neutral"
            ]
          }
        },
        "required": [
          "topics",
          "sentiment"
        ]
      }
    },
    "temperature": 0.2,
    "max_tokens": 4096
  },
  "completed_at": "2026-04-13T10:14:47Z",
  "result": {
    "generation_id": "3fc396f4-0c4c-4198-baac-b1d506f07bf8",
    "data": "{\"topics\": [\"product launch\", \"innovation\"], \"sentiment\": \"positive\"}",
    "finish_reason": "stop",
    "usage": {
      "output_tokens": 80
    }
  }
}
```

**SDK Code**

```python Task ready with structured JSON results
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with structured JSON results
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with structured JSON results
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with structured JSON results
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with structured JSON results
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with structured JSON results
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with structured JSON results
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with structured JSON results
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with `timestamp` fields

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d13",
  "custom_id": null,
  "status": "ready",
  "created_at": "2026-04-13T10:13:23Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/video.mp4",
    "system_metadata": {
      "duration": 336.387483
    }
  },
  "request_params": {
    "analysis_mode": "general",
    "prompt": "Identify intro, main content, and outro clips.",
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "type": "object",
        "properties": {
          "clip_start": {
            "type": "timestamp",
            "format": "seconds"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "intro_end": {
                  "type": "timestamp",
                  "format": "hh:mm:ss"
                },
                "outro_start": {
                  "type": "timestamp",
                  "format": "hh:mm:ss.fff"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "temperature": 0.2,
    "max_tokens": 4096,
    "model_name": "pegasus1.5"
  },
  "completed_at": "2026-04-13T10:14:47Z",
  "result": {
    "generation_id": "3fc396f4-0c4c-4198-baac-b1d506f07bf9",
    "data": "{\"clip_start\": 12.5, \"events\": [{\"intro_end\": \"00:00:30\", \"outro_start\": \"00:02:00.500\", \"label\": \"intro\"}, {\"intro_end\": \"00:00:46\", \"outro_start\": \"00:05:00.789\", \"label\": \"main\"}]}",
    "finish_reason": "stop",
    "usage": {
      "output_tokens": 120,
      "input_tokens": 9420
    }
  }
}
```

**SDK Code**

```python Task ready with `timestamp` fields
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with `timestamp` fields
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with `timestamp` fields
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with `timestamp` fields
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with `timestamp` fields
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with `timestamp` fields
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with `timestamp` fields
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with `timestamp` fields
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with video segmentation results

**Response**

```json
{
  "task_id": "69dcdd9b1971c7bf19c63fe1",
  "custom_id": null,
  "status": "ready",
  "created_at": "2026-04-13T10:13:23Z",
  "video_source": {
    "type": "asset_id",
    "asset_id": "698ae3f3f4a786d35a6303e1",
    "system_metadata": {
      "duration": 336.387483
    }
  },
  "request_params": {
    "analysis_mode": "time_based_metadata",
    "response_format": {
      "type": "segment_definitions",
      "segment_definitions": [
        {
          "id": "shot_changes",
          "description": "Find all shot changes",
          "fields": [
            {
              "name": "activity",
              "type": "string",
              "description": "What the person is doing"
            }
          ]
        }
      ]
    },
    "temperature": 0.2,
    "max_tokens": 4096
  },
  "completed_at": "2026-04-13T10:14:47Z",
  "result": {
    "generation_id": "3fc396f4-0c4c-4198-baac-b1d506f07bf8",
    "data": "{\"shot_changes\": [{\"start_time\": 0.0, \"end_time\": 2.0, \"metadata\": {\"activity\": \"Steve Jobs walks onto the stage\"}}, {\"start_time\": 2.0, \"end_time\": 13.0, \"metadata\": {\"activity\": \"Steve Jobs stands on stage with the Apple logo in the background\"}}]}",
    "finish_reason": "stop",
    "usage": {
      "output_tokens": 150,
      "input_tokens": 9420
    }
  }
}
```

**SDK Code**

```python Task ready with video segmentation results
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with video segmentation results
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with video segmentation results
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with video segmentation results
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with video segmentation results
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with video segmentation results
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with video segmentation results
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with video segmentation results
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with `segment_time_format` and a `timestamp` field

**Response**

```json
{
  "task_id": "69dcdd9b1971c7bf19c63fe2",
  "custom_id": null,
  "status": "ready",
  "created_at": "2026-04-13T10:13:23Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/video.mp4",
    "system_metadata": {
      "duration": 336.387483
    }
  },
  "request_params": {
    "analysis_mode": "time_based_metadata",
    "response_format": {
      "type": "segment_definitions",
      "segment_definitions": [
        {
          "id": "scenes",
          "description": "Detect scenes and label them.",
          "fields": [
            {
              "name": "label",
              "type": "string",
              "description": "A short label for this scene."
            },
            {
              "name": "highlight_at",
              "type": "timestamp",
              "description": "The single most representative moment in this scene.",
              "format": "seconds"
            }
          ]
        }
      ],
      "segment_time_format": "hh:mm:ss"
    },
    "temperature": 0.2,
    "max_tokens": 4096,
    "model_name": "pegasus1.5"
  },
  "completed_at": "2026-04-13T10:14:47Z",
  "result": {
    "generation_id": "3fc396f4-0c4c-4198-baac-b1d506f07bfa",
    "data": "{\"scenes\": [{\"start_time\": \"00:00:00\", \"end_time\": \"00:00:13\", \"metadata\": {\"label\": \"intro\", \"highlight_at\": 5}}, {\"start_time\": \"00:00:13\", \"end_time\": \"00:00:30\", \"metadata\": {\"label\": \"main\", \"highlight_at\": 18}}]}",
    "finish_reason": "stop",
    "usage": {
      "output_tokens": 160,
      "input_tokens": 9420
    }
  }
}
```

**SDK Code**

```python Task ready with `segment_time_format` and a `timestamp` field
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with `segment_time_format` and a `timestamp` field
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with `segment_time_format` and a `timestamp` field
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with `segment_time_format` and a `timestamp` field
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with `segment_time_format` and a `timestamp` field
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with `segment_time_format` and a `timestamp` field
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with `segment_time_format` and a `timestamp` field
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with `segment_time_format` and a `timestamp` field
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with truncated output: maximum response length reached

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d14",
  "custom_id": null,
  "status": "ready",
  "created_at": "2026-05-26T10:13:23Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/video.mp4",
    "system_metadata": {
      "duration": 336.387483
    }
  },
  "request_params": {
    "analysis_mode": "general",
    "prompt": "Provide an exhaustive scene-by-scene breakdown of this video, including dialogue transcription, visual descriptions, and emotional analysis.",
    "temperature": 0.2,
    "max_tokens": 2048,
    "model_name": "pegasus1.5"
  },
  "completed_at": "2026-05-26T10:16:12Z",
  "result": {
    "generation_id": "3fc396f4-0c4c-4198-baac-b1d506f07bfb",
    "data": "Scene 1 (0:00–0:12): The video opens on a wide shot of a city skyline at dawn. Sunlight reflects off the glass facades of high-rise buildings while traffic begins to build on the streets below. The narrator introduces the topic with a calm, measured voice. Scene 2 (0:12–0:45): The camera cuts to a close-up of a coffee shop interior, where a",
    "finish_reason": "length",
    "usage": {
      "output_tokens": 2048,
      "input_tokens": 9420
    }
  },
  "error": {
    "message": "output truncated: the generation reached the configured max_tokens. The partial output is returned; raise max_tokens if you need a longer response."
  }
}
```

**SDK Code**

```python Task ready with truncated output: maximum response length reached
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with truncated output: maximum response length reached
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with truncated output: maximum response length reached
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with truncated output: maximum response length reached
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with truncated output: maximum response length reached
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with truncated output: maximum response length reached
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with truncated output: maximum response length reached
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with truncated output: maximum response length reached
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task ready with truncated output: context window reached

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d15",
  "custom_id": null,
  "status": "ready",
  "created_at": "2026-05-26T10:13:23Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/long-video.mp4",
    "system_metadata": {
      "duration": 3580.42
    }
  },
  "request_params": {
    "analysis_mode": "general",
    "prompt": "Provide an exhaustive scene-by-scene breakdown of this video, including dialogue transcription, visual descriptions, and emotional analysis.",
    "temperature": 0.2,
    "max_tokens": 98304,
    "model_name": "pegasus1.5"
  },
  "completed_at": "2026-05-26T10:18:51Z",
  "result": {
    "generation_id": "3fc396f4-0c4c-4198-baac-b1d506f07bfc",
    "data": "Scene 1 (0:00–0:12): The video opens on a wide shot of a city skyline at dawn. Sunlight reflects off the glass facades of high-rise buildings while traffic begins to build on the streets below. The narrator introduces the topic with a calm, measured voice. Scene 2 (0:12–0:45): The camera cuts to a close-up of a coffee shop interior, where a",
    "finish_reason": "length",
    "usage": {
      "output_tokens": 8192,
      "input_tokens": 252928
    }
  },
  "error": {
    "message": "output truncated: combined input and output tokens reached the model's context limit. The partial output is returned; consider reducing input size (shorter prompt, smaller video clip, fewer media bindings) or lowering max_tokens."
  }
}
```

**SDK Code**

```python Task ready with truncated output: context window reached
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task ready with truncated output: context window reached
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task ready with truncated output: context window reached
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task ready with truncated output: context window reached
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task ready with truncated output: context window reached
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task ready with truncated output: context window reached
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task ready with truncated output: context window reached
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task ready with truncated output: context window reached
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task failed: time_based_metadata output truncated

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d16",
  "custom_id": null,
  "status": "failed",
  "created_at": "2026-09-10T02:09:07Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/video.mp4",
    "system_metadata": {
      "duration": 160.52
    }
  },
  "request_params": {
    "analysis_mode": "time_based_metadata",
    "temperature": 0.2,
    "max_tokens": 2048,
    "min_segment_duration": 2
  },
  "completed_at": "2026-09-10T02:09:46Z",
  "error": {
    "message": "analysis failed: the time_based_metadata output reached the configured max_tokens before a complete result was produced. Raise max_tokens if it is below the per-model maximum; otherwise narrow the request (fewer segment_definitions or fields, a larger min_segment_duration, or a shorter analysis window)."
  }
}
```

**SDK Code**

```python Task failed: time_based_metadata output truncated
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task failed: time_based_metadata output truncated
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task failed: time_based_metadata output truncated
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Task failed: time_based_metadata output truncated
require 'uri'
require 'net/http'

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

```java Task failed: time_based_metadata output truncated
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

```php Task failed: time_based_metadata output truncated
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task failed: time_based_metadata output truncated
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task failed: time_based_metadata output truncated
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task failed

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d12",
  "custom_id": null,
  "status": "failed",
  "created_at": "2024-09-26T10:29:19.968Z",
  "completed_at": "2024-09-26T10:30:00.000Z",
  "error": {
    "message": "Video duration exceeds maximum allowed duration"
  }
}
```

**SDK Code**

```python Task failed
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task failed
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task failed
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

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

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task failed
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task failed
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```

### Task canceled

**Response**

```json
{
  "task_id": "64f8d2c7e4a1b37f8a9c5d16",
  "custom_id": null,
  "status": "canceled",
  "created_at": "2026-09-14T10:29:19Z",
  "video_source": {
    "type": "url",
    "url": "https://example.com/video.mp4",
    "system_metadata": {
      "duration": 120.5
    }
  },
  "completed_at": "2026-09-14T10:29:30Z",
  "error": {
    "message": "The task was canceled by the user.",
    "code": "user_canceled"
  }
}
```

**SDK Code**

```python Task canceled
import requests

url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

headers = {"x-api-key": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Task canceled
const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12';
const options = {method: 'GET', headers: {'x-api-key': '<apiKey>'}};

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

```go Task canceled
package main

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

func main() {

	url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

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

url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")

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

request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.get("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Task canceled
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Task canceled
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```