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

# Get a Batch

> Retrieve a [Batch](/core-resources/batch) from its `batch_id` or `batch_name`.

<Accordion title="Authentication" icon="key">
  Every request sent to Scale's API requires authentication. In short, your API Key is the Bearer token. See the [Authentication](/get-started/authentication) section for more details.
</Accordion>

<Tip>
  ### Required query parameters

  You are expected to provide one of the following:

  * **Batch ID** (`batch_id`)
  * **Batch Name** (`batch_name`)
</Tip>


## OpenAPI

````yaml GET /v2/batch
openapi: 3.1.0
info:
  title: GenAI API Spec
  description: 'Data Engine: Generative AI API Specification'
  version: 0.0.1
servers:
  - url: https://api.scale.com
security:
  - bearerAuth: []
  - basicAuth: []
paths:
  /v2/batch:
    get:
      tags:
        - v2
      summary: Get a Batch
      description: >-
        Retrieve a [Batch](/core-resources/batch) from its `batch_id` or
        `batch_name`.
      operationId: getBatch
      parameters:
        - $ref: '#/components/parameters/batch_id'
        - $ref: '#/components/parameters/batch_name'
        - $ref: '#/components/parameters/expand_batch'
      responses:
        '200':
          description: Batch details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Batch'
              examples:
                Sample Batch:
                  $ref: '#/components/examples/SampleBatch'
        '500':
          description: Error response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status_code:
                    type: number
                    example: 500
                  error:
                    type: string
                    example: An error has occurred.
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |
            API_KEY='live_...'
            BATCH_ID='batch_123'
            curl --request GET \
                --url "https://api.scale.com/v2/batch?batch_id=$BATCH_ID" \
                --header "Authorization: Bearer $API_KEY"
        - lang: python
          label: Python SDK
          source: |
            import scaleapi

            API_KEY = 'live_...'
            client = scaleapi.ScaleClient(API_KEY)

            BATCH_ID = 'batch_123'
            response = client.v2.get_batch(BATCH_ID)
            print(response.to_json())
        - lang: python
          label: Python
          source: |
            import requests

            API_KEY = 'live_...'
            BATCH_ID = 'batch_123'

            response = requests.request(
              "GET",
              url="https://api.scale.com/v2/batch",
              params={"batch_id": BATCH_ID},
              headers={
                "Accept": "application/json",
                "Authorization": f"Bearer {API_KEY}",
              },
            )
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >
            const API_KEY = 'live_...';

            const BATCH_ID = 'batch_123';


            const params = new URLSearchParams({ batch_id: BATCH_ID });


            const response = await fetch('https://api.scale.com/v2/batch?' +
            params.toString(), {
              method: 'GET',
              headers: {
                Accept: 'application/json',
                Authorization: `Bearer ${API_KEY}`,
              },
            });

            console.log(await response.json());
        - lang: go
          label: Go
          source: |
            package main

            import (
              "fmt"

              "io/ioutil"
              "net/http"
            )

            func main() {
              apiKey := "live_..."
              batchId := "batch_123"

              url := fmt.Sprintf("https://api.scale.com/v2/batch?batch_id=%s", batchId)

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

              req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", apiKey))

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

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

              fmt.Println(string(body))
            }
        - lang: java
          label: Java
          source: |
            package com.scale.api;

            import kong.unirest.HttpResponse;
            import kong.unirest.Unirest;

            public class App {
                public static void main(String[] args) {
                    String apiKey = "live_...";
                    String batchId = "batch_123";

                    String url = String.format("https://api.scale.com/v2/batch?batch_id=%s", batchId);

                    HttpResponse<String> response = Unirest.get(url)
                      .header("Authorization", String.format("Bearer %s", apiKey))
                      .asString();

                    System.out.println(response.getBody());
                }
            }
components:
  parameters:
    batch_id:
      name: batch_id
      in: query
      required: false
      description: Scale's unique identifier for the batch.
      schema:
        $ref: '#/components/schemas/BatchId'
    batch_name:
      name: batch_name
      in: query
      required: false
      description: The name of the batch.
      schema:
        $ref: '#/components/schemas/BatchName'
    expand_batch:
      name: expand
      in: query
      required: false
      description: >-
        List of fields to [expand](/api-reference/expanding-entities) in the
        response.
      schema:
        $ref: '#/components/schemas/ExpandBatch'
  schemas:
    Batch:
      type: object
      required:
        - id
        - name
        - project
        - created_at
        - status
        - metadata
      properties:
        id:
          $ref: '#/components/schemas/BatchId'
        name:
          $ref: '#/components/schemas/BatchName'
        project:
          $ref: '#/components/schemas/ExpandableProject'
          description: >-
            Project ID or [Project](/core-resources/project) associated with the
            batch.
        created_at:
          $ref: '#/components/schemas/DateString'
        completed_at:
          $ref: '#/components/schemas/DateString'
          description: UTC timestamp when the batch was completed.
        status:
          $ref: '#/components/schemas/BatchStatus'
        callback:
          $ref: '#/components/schemas/Callback'
        metadata:
          $ref: '#/components/schemas/BatchMetadata'
    BatchId:
      type: string
      description: A unique identifier for the batch.
      example: batch_abc123
    BatchName:
      type: string
      description: The name of the batch.
      example: My Scale Batch
    ExpandBatch:
      type: array
      description: >-
        Entities that can be [expanded](/api-reference/expanding-entities) from
        an ID to an object.
      items:
        $ref: '#/components/schemas/ExpandableEnumBatch'
    ExpandableProject:
      description: >-
        Project ID or [Project](/core-resources/project) associated with the
        task.
      oneOf:
        - $ref: '#/components/schemas/ProjectId'
        - $ref: '#/components/schemas/Project'
    DateString:
      type: string
      format: date-time
      description: A timestamp formatted as an ISO 8601 date-time string.
    BatchStatus:
      type: string
      enum:
        - staging
        - in_progress
        - completed
        - paused
        - cancelled
      description: Status of the batch.
    Callback:
      type: string
      description: Callback URL or email for the entity upon completion.
      example: https://example.com/callback
    BatchMetadata:
      $ref: '#/components/schemas/Metadata'
    ExpandableEnumBatch:
      type: string
      description: Entities that can be expanded from an ID to an object.
      enum:
        - project
    ProjectId:
      type: string
      description: A unique identifier for the project.
      example: project_abc123
    Project:
      type: object
      required:
        - id
        - name
        - created_at
      properties:
        id:
          $ref: '#/components/schemas/ProjectId'
          description: Unique identifier for the project
        name:
          $ref: '#/components/schemas/ProjectName'
        created_at:
          $ref: '#/components/schemas/DateString'
        types:
          type: array
          description: List of project types associated with the project.
          items:
            $ref: '#/components/schemas/GenAIProjectType'
          example:
            - 'RLHF: Pref Ranking'
        models:
          type: array
          description: List of models associated with the project.
          items:
            $ref: '#/components/schemas/Model'
          example:
            - gpt-4
            - my-model-123
    Metadata:
      type: object
      description: Custom metadata for the entity.
      additionalProperties: true
      default: {}
    ProjectName:
      type: string
      description: The name of the project.
      example: My Scale Project
    GenAIProjectType:
      type: string
      enum:
        - SFT
        - 'RLHF: Pref Ranking'
        - 'RLHF: Pref Ranking with Rewrites'
        - 'RLVR: Reinforcement Learning with Verifiable Rewards'
        - Rubrics
        - Process Supervision
        - Evals
        - Prompt Generation
        - Content Understanding
        - Other
    Model:
      type: string
      description: The name of the model that generated the message.
      example: my-model-123
  examples:
    SampleBatch:
      value:
        id: batch_123
        name: Batch Name Example
        project: project_123
        created_at: '2022-07-25T07:32:34.318Z'
        status: completed
        callback: https://example.com/callback
        metadata: {}
        completed_at: '2022-07-26T07:32:34.318Z'
  securitySchemes:
    bearerAuth:
      description: >-
        Your API Key is the Bearer token. See the
        [Authentication](/get-started/authentication) section to learn how to
        access your key.
      type: http
      scheme: bearer
    basicAuth:
      description: >-
        Basic HTTP Authentication. Your API Key is your username.  Learn more
        about setting up Authentication [here](/get-started/authentication).
      type: http
      scheme: basic

````