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

# Fetch Job Details

> Retrieve details for a specific job by its ID

<Warning>Using the API directly is not recommended for most users. Instead, we recommend using the [Python SDK](/python-sdk/setup).</Warning>

Retrieve detailed information about a specific job using its job ID.

## Path Parameters

<ParamField path="job_id" type="string" required>
  The unique identifier of the job to retrieve.

  Example: `job-xyz123...`
</ParamField>

## Headers

<ParamField header="Authorization" type="string" required>
  Your Sutro API key using Key authentication scheme.

  Format: `Key YOUR_API_KEY`

  Example: `Authorization: Key sk_abc123...`
</ParamField>

## Response

<ResponseField name="job" type="object">
  The job object containing all metadata and status information for the requested job. See the [job object fields](#job-object-fields) section for detailed field descriptions.
</ResponseField>

### Error Response

Returns a 404 status code if the job is not found.

<ResponseField name="message" type="string">
  Error message indicating the job was not found
</ResponseField>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "job": {
      "model": "llama-3.1-8b",
      "system_prompt": "You are a helpful assistant.",
      "job_priority": 1,
      "status": "succeeded",
      "datetime_created": "2024-01-15T10:30:00Z",
      "datetime_started": "2024-01-15T10:30:15Z",
      "datetime_completed": "2024-01-15T10:32:15Z",
      "json_schema": null,
      "sampling_params": {
        "temperature": 0.7,
        "top_p": 0.95,
        "max_tokens": 2048
      },
      "name": "Customer Support Batch",
      "description": "Processing customer inquiries",
      "dataset_id": "dataset-12345",
      "input_tokens": 15420,
      "output_tokens": 8230,
      "job_cost": 0.0234,
      "num_rows": 50,
      "failure_reason": null,
      "cost_estimate": 0.025,
      "job_id": "job-12345"
    }
  }
  ```

  ```json Error Response theme={null}
  {
    "message": "No job found with ID batch_job_99999"
  }
  ```
</ResponseExample>

## Code Examples

<CodeGroup>
  ```python Python theme={null}
  import requests

  job_id = "job-12345"
  response = requests.get(
      f'https://api.sutro.sh/jobs/{job_id}',
      headers={'Authorization': 'Key YOUR_SUTRO_API_KEY'}
  )

  if response.status_code == 200:
      job = response.json()['job']
      print(f"Job ID: {job['job_id']}")
      print(f"Status: {job['status']}")
      print(f"Model: {job['model']}")
      print(f"Created: {job['datetime_created']}")

      if job['status'] == 'succeeded':
          print(f"Rows processed: {job['num_rows']}")
          print(f"Cost: ${job['job_cost']:.4f}")
          print(f"Tokens: {job['input_tokens']} in, {job['output_tokens']} out")
      elif job['status'] == 'failed':
          print(f"Failure reason: {job['failure_reason']}")
  elif response.status_code == 404:
      print(f"Job not found: {job_id}")
  else:
      print(f"Error: {response.status_code}")
  ```

  ```javascript Node.js theme={null}
  const jobId = 'batch_job_12345';

  const response = await fetch(`https://api.sutro.sh/jobs/${jobId}`, {
    headers: {
      'Authorization': 'Key YOUR_SUTRO_API_KEY'
    }
  });

  if (response.ok) {
    const data = await response.json();
    const job = data.job;

    console.log(`Job ID: ${job.job_id}`);
    console.log(`Status: ${job.status}`);
    console.log(`Model: ${job.model}`);

    if (job.status === 'succeeded') {
      console.log(`Rows processed: ${job.num_rows}`);
      console.log(`Cost: $${job.job_cost.toFixed(4)}`);
      console.log(`Tokens: ${job.input_tokens} in, ${job.output_tokens} out`);
    } else if (job.status === 'failed') {
      console.log(`Failure reason:`, job.failure_reason);
    }
  } else if (response.status === 404) {
    console.log(`Job not found: ${jobId}`);
  }
  ```

  ```curl cURL theme={null}
  # Get job details
  curl -X GET "https://api.sutro.sh/jobs/batch_job_12345" \
    -H "Authorization: Key YOUR_SUTRO_API_KEY"

  # Pretty print with jq
  curl -s -X GET "https://api.sutro.sh/jobs/batch_job_12345" \
    -H "Authorization: Key YOUR_SUTRO_API_KEY" | jq '.job'

  # Check job status only
  curl -s -X GET "https://api.sutro.sh/jobs/batch_job_12345" \
    -H "Authorization: Key YOUR_SUTRO_API_KEY" | jq -r '.job.status'
  ```
</CodeGroup>

## Job Object Fields

The job object returned contains the same fields as documented in the [List Jobs endpoint](/batch-api-reference/list-jobs#job-object-fields):

| Field                | Type            | Description                                                           |
| -------------------- | --------------- | --------------------------------------------------------------------- |
| `job_id`             | string          | Public identifier for the job                                         |
| `status`             | string          | Current status of the job (SUCCEEDED, FAILED, RUNNING, PENDING, etc.) |
| `model`              | string          | The model used for the job                                            |
| `system_prompt`      | string \| null  | System prompt used for the job                                        |
| `job_priority`       | integer         | Priority level of the job (0 or 1)                                    |
| `datetime_created`   | string          | ISO timestamp of when the job was created                             |
| `datetime_started`   | string \| null  | ISO timestamp of when processing began                                |
| `datetime_completed` | string \| null  | ISO timestamp of when the job completed                               |
| `json_schema`        | object \| null  | JSON schema for structured output (if used)                           |
| `sampling_params`    | object          | Sampling parameters used for generation                               |
| `name`               | string \| null  | Optional name for the job                                             |
| `description`        | string \| null  | Optional description of the job                                       |
| `dataset_id`         | string \| null  | Associated dataset identifier                                         |
| `input_tokens`       | integer \| null | Total input tokens processed                                          |
| `output_tokens`      | integer \| null | Total output tokens generated                                         |
| `job_cost`           | number \| null  | Actual cost of the job in USD                                         |
| `num_rows`           | integer \| null | Number of rows processed                                              |
| `failure_reason`     | object \| null  | Details if the job failed                                             |
| `cost_estimate`      | number \| null  | Estimated cost before processing                                      |

## Notes

* This endpoint retrieves a single job's complete metadata
* The `job_cost` field represents the actual cost incurred after processing completes
* For jobs still in progress, completion-related fields will be `null`
