> ## 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 template run

> Runs the failed pages of a finished run again, with the run's original inputs, and leaves the rest alone. The run goes back to `running`, so poll [Get a template run](/api-reference/templates/get-run) as before. Each failure in `failures` has a `code` (such as `blocked` or `not_found`) to decide whether a retry is worth it.

Works on runs of a single step. Runs with a second step (such as checking each website for contacts) or that run many searches answer `409` with `RETRY_NOT_SUPPORTED`; start a new run instead.

**Credits:** only the retried pages, at the template's usual price. A page that fails again costs nothing.




## OpenAPI

````yaml POST /template-runs/{runId}/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` or `x-api-key: YOUR_API_KEY`; both work
    on every endpoint.
servers:
  - url: https://api.spidra.io/api
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /template-runs/{runId}/retry:
    post:
      tags:
        - Templates
      summary: Retry a template run's failed pages
      description: >
        Runs the failed pages of a finished run again, with the run's original
        inputs, and leaves the rest alone. The run goes back to `running`, so
        poll [Get a template run](/api-reference/templates/get-run) as before.
        Each failure in `failures` has a `code` (such as `blocked` or
        `not_found`) to decide whether a retry is worth it.


        Works on runs of a single step. Runs with a second step (such as
        checking each website for contacts) or that run many searches answer
        `409` with `RETRY_NOT_SUPPORTED`; start a new run instead.


        **Credits:** only the retried pages, at the template's usual price. A
        page that fails again costs nothing.
      parameters:
        - name: runId
          in: path
          required: true
          description: The `runId` returned when the run started.
          schema:
            type: string
            format: uuid
          example: dfefa844-ad1f-4400-b127-dc17a186d9c2
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                cookies:
                  type: string
                  description: >-
                    Cookies are never stored. Send them again if the run used
                    them.
      responses:
        '202':
          description: The failed pages are running again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  retriedCount:
                    type: integer
                    description: How many pages are running again.
                  warnings:
                    type: array
                    items:
                      type: string
                  run:
                    $ref: '#/components/schemas/TemplateRun'
              example:
                status: success
                retriedCount: 1
                run:
                  runId: cba40eaa-3593-41c2-8688-d0984d255695
                  template: github-repo-details
                  status: running
        '400':
          description: '`NO_FAILED_PAGES`: the run has no failed pages.'
        '404':
          description: No run with this ID.
        '409':
          description: >-
            `RUN_RUNNING`: the run hasn't finished yet. `RETRY_NOT_SUPPORTED`:
            the run has more than one step.
components:
  schemas:
    TemplateRun:
      type: object
      description: A template run, with its rows once it has finished.
      properties:
        runId:
          type: string
          format: uuid
          description: The run's ID. Use it with `GET /template-runs/{runId}`.
        template:
          type: string
          description: The template's slug.
        templateVersion:
          type: integer
          description: The template version the run used.
        presetId:
          type:
            - string
            - 'null'
          description: The preset the run was started from, or `null`.
        tool:
          type: string
          enum:
            - batch
            - search
            - map
            - crawl
            - parse
          description: The Spidra tool behind the run.
        status:
          type: string
          enum:
            - running
            - completed
            - partial
            - failed
            - cancelled
          description: >
            - `running`: still reading pages.

            - `completed`: finished. `rows` holds the results.

            - `partial`: some pages couldn't be read, or a second step failed.
            The pages that failed are in `failures` and aren't charged. `rows`
            holds the rest.

            - `failed`: nothing could be read. `error` says why, and you aren't
            charged.

            - `cancelled`: the job behind the run was cancelled.
        inputs:
          type: object
          description: The inputs the run used, with defaults filled in.
        createdAt:
          type: string
          format: date-time
          description: When the run started.
        finishedAt:
          type:
            - string
            - 'null'
          format: date-time
          description: When the run finished, or `null` while it runs.
        creditsUsed:
          type:
            - number
            - 'null'
          description: Credits the run cost. `null` until it has finished.
        urlCount:
          type:
            - integer
            - 'null'
          description: How many pages or searches the run started with.
        rowCount:
          type:
            - integer
            - 'null'
          description: How many rows the run returned.
        progress:
          type: object
          description: >-
            Pages done so far. With a second step, its pages are added once
            they're queued.
          properties:
            completed:
              type: integer
              description: Pages read.
            failed:
              type: integer
              description: Pages that couldn't be read.
            total:
              type: integer
              description: Pages known so far.
        rows:
          type: array
          items:
            type: object
          description: >-
            The results, one object per row, once the run has finished. Each row
            has every field the site returned, not only the template's default
            `columns`. Left out with `?rows=false`.
        failures:
          type: array
          description: Pages that couldn't be read. They aren't charged.
          items:
            type: object
            properties:
              url:
                type: string
                description: The page.
              error:
                type: string
                description: Why it couldn't be read.
              code:
                type: string
                enum:
                  - not_found
                  - no_results
                  - login_required
                  - blocked
                  - timeout
                  - empty_content
                  - invalid_input
                  - unsupported
                  - out_of_credits
                  - failed
                description: >
                  Why the page failed, as a stable code to branch on:


                  - `not_found`: the link points at nothing (no such page,
                  company or place).

                  - `no_results`: the search or list exists but has nothing
                  matching.

                  - `login_required`: only signed-in users can see it. Spidra
                  reads public pages only.

                  - `blocked`: the site refused or challenged every attempt.

                  - `timeout`: the page took too long.

                  - `empty_content`: the page loaded but held no usable data.

                  - `invalid_input`: the input can't be used as given.

                  - `unsupported`: this kind of page isn't read.

                  - `out_of_credits`

                  - `failed`: anything else.
        error:
          type: string
          description: >-
            Only when the run failed, or ended `partial` because its second step
            failed. Why.
        followStep:
          type: object
          description: >-
            Only on templates with a second step switched on, such as **Find
            emails and social links**. The run stays `running` until this step
            has finished, and its fields are merged into each row.
          properties:
            status:
              type: string
              enum:
                - waiting
                - running
                - completed
                - failed
              description: Where the second step is.
            sites:
              type: integer
              description: Websites the step checks.
            pagesLoaded:
              type: integer
              description: Pages it read.
            pagesFailed:
              type: integer
              description: Pages it couldn't read. These aren't charged.
            pagesWaiting:
              type: integer
              description: Pages still to read.
            creditsUsed:
              type: integer
              description: Credits the step cost.
            error:
              type: string
              description: Only when the step failed. Why.
        summary:
          type: object
          description: >-
            Only on rank trackers. How many keywords or points ranked, and the
            average position.
        job:
          type: object
          description: >-
            The tool job behind the run. For crawl and parse templates, the full
            result is at that tool's own endpoint, such as [Get a
            crawl](/api-reference/crawling/crawl-status).
          properties:
            tool:
              type: string
              enum:
                - batch
                - search
                - map
                - crawl
                - parse
              description: The tool.
            id:
              type:
                - string
                - 'null'
              description: The tool job's ID, or `null` when there's none to read.
        resultsPath:
          type: string
          description: >-
            Only for crawl and parse templates. The dashboard page with the full
            result.
  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.