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

# Retry a batch

> Runs a batch's failed URLs again with the batch's original options, and leaves the rest alone. The batch goes back to `running`, so poll [Get a batch](/api-reference/scraping/batch-scrape-status) as before.

Cookies are never stored. If the batch used them, send them again in `cookies`. Without them, the retried URLs run logged out and the response has a `warnings` entry saying so.

**Credits:** the same as the first run. 1 credit is held for each retried URL, and a URL that fails again costs nothing.

**Rate limits:** no per-minute limit, but the retried URLs count toward your 50 unfinished URLs.




## OpenAPI

````yaml POST /batch/scrape/{batchId}/retry
openapi: 3.1.0
info:
  title: Spidra API
  version: 1.0.0
  description: >-
    Public API endpoints for web scraping via Spidra. Authenticate with
    `Authorization: Bearer YOUR_API_KEY`.
servers:
  - url: https://api.spidra.io/api
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /batch/scrape/{batchId}/retry:
    post:
      tags:
        - Batch Scraping
      summary: Retry a batch
      description: >
        Runs a batch's failed URLs again with the batch's original options, and
        leaves the rest alone. The batch goes back to `running`, so poll [Get a
        batch](/api-reference/scraping/batch-scrape-status) as before.


        Cookies are never stored. If the batch used them, send them again in
        `cookies`. Without them, the retried URLs run logged out and the
        response has a `warnings` entry saying so.


        **Credits:** the same as the first run. 1 credit is held for each
        retried URL, and a URL that fails again costs nothing.


        **Rate limits:** no per-minute limit, but the retried URLs count toward
        your 50 unfinished URLs.
      parameters:
        - name: batchId
          in: path
          required: true
          description: The `batchId` returned by `POST /batch/scrape`.
          schema:
            type: string
            format: uuid
          example: 38ae74ab-3a7f-421f-9d02-50c6b48d8c49
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                cookies:
                  type: string
                  description: >-
                    The cookies to send with the retried URLs, when the batch
                    needed them. Either `name=value; name2=value2` or rows
                    pasted from your browser's DevTools. Never stored.
            examples:
              empty:
                summary: Retry with the original options
                value: {}
      responses:
        '202':
          description: The failed URLs were queued again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - queued
                  retriedCount:
                    type: integer
                    description: How many failed URLs were queued again.
                  warnings:
                    type: array
                    items:
                      type: string
                    description: >-
                      Only when the batch used cookies and you didn't send them
                      again, so the retried URLs run logged out.
              examples:
                queued:
                  summary: Queued
                  value:
                    status: queued
                    retriedCount: 1
                no_cookies:
                  summary: Queued, without the batch's cookies
                  value:
                    status: queued
                    retriedCount: 1
                    warnings:
                      - >-
                        This batch was sent with cookies, and cookies are never
                        stored, so the retried URLs run logged out. Send
                        "cookies" in the retry request to keep them signed in.
        '400':
          description: None of the batch's URLs have failed, so there's nothing to retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: No failed items to retry.
                code: NO_FAILED_ITEMS
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            The account's payment is overdue. Update the payment method in the
            dashboard to continue.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  Your payment is overdue. Please update your payment method to
                  continue.
                code: PAYMENT_OVERDUE
        '403':
          description: >-
            Your account doesn't have enough credits to hold 1 credit for every
            retried URL. Top up or upgrade, then try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: You have exceeded your monthly credit limit.
        '404':
          description: There's no batch with this ID on your account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: Batch scrape job not found.
        '409':
          description: The batch was cancelled. Start a new batch instead.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                code: BATCH_CANCELLED
                message: This batch was cancelled. Start a new batch instead.
        '422':
          description: '`cookies` isn''t a string.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  "cookies" must be a cookie string such as "name=value;
                  other=value".
                errors:
                  - >-
                    "cookies" must be a cookie string such as "name=value;
                    other=value".
        '429':
          description: >-
            The retried URLs would take you past 50 unfinished URLs across your
            batches and scrapes. Wait for some to finish, then try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  You have too many pending scrape jobs. Please wait for your
                  current batch to complete before retrying.
                code: TOO_MANY_PENDING_JOBS
        '500':
          description: >-
            The URLs couldn't be queued again. The credits held for them were
            returned. Try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                requeue:
                  summary: Couldn't queue the URLs
                  value:
                    status: error
                    message: Failed to retry items. Your credits have been refunded.
                    code: RETRY_FAILED
                other:
                  summary: Something else went wrong
                  value:
                    status: error
                    message: Failed to retry batch items
                    code: INTERNAL_ERROR
        '503':
          description: Spidra is at capacity. Wait `retry_after` seconds, then try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  The scraping service is currently at capacity. Please retry in
                  a few minutes.
                code: SERVICE_BUSY
                retry_after: 60
components:
  schemas:
    ErrorResponse:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: What went wrong, as a sentence you can show to a person.
        code:
          type: string
          description: >-
            A stable code for the error, when there is one, such as
            `JOB_NOT_FOUND` or `SERVICE_BUSY`. Branch on this rather than on
            `message`.
        errors:
          description: >-
            On validation errors (`422`), every problem with the request.
            Scrape, batch, crawl, map and search return a list of sentences.
            Templates, presets and monitors return `{ field, message }` objects.
          oneOf:
            - type: array
              items:
                type: string
            - type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
        retry_after:
          type: integer
          description: >-
            On `503 SERVICE_BUSY`, how many seconds to wait before sending the
            request again.
  responses:
    Unauthorized:
      description: The API key is missing, wrong, or turned off.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing:
              summary: No key sent
              value:
                status: error
                message: Missing authentication
            invalid:
              summary: Wrong or turned-off key
              value:
                status: error
                message: Invalid token or API key
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.