> ## 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.

# Estimate a Template Run

> Check inputs and see what a template run will cost, without running it.

Checks the inputs the same way a run does and returns the credits a run should cost. It's free and needs no API key, so it's also a quick way to validate inputs.

```bash theme={null}
curl -X POST https://api.spidra.io/api/templates/google-maps-leads/estimate \
  -H "Content-Type: application/json" \
  -d '{ "inputs": { "query": "dentist", "areas": ["Lekki, Lagos"] } }'
```

```json theme={null}
{ "status": "success", "credits": 1, "note": null, "pages": 1 }
```

`note` explains what can add to the number, such as AI tokens or a second step that visits each website. `credits` is `null` when the cost can't be known in advance.

Inputs that need fixing return `422`:

```json theme={null}
{
  "status": "error",
  "code": "INVALID_INPUT",
  "message": "Some inputs need fixing.",
  "errors": [
    { "field": "query", "message": "Business type is required." },
    { "field": "areas", "message": "Areas is required." }
  ]
}
```


## OpenAPI

````yaml POST /templates/{slug}/estimate
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:
  /templates/{slug}/estimate:
    post:
      tags:
        - Templates
      summary: Estimate a Template Run
      description: >-
        Checks the inputs and returns what a run would cost, without running it.
        Free, no API key needed.
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            type: string
          description: The template's slug.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                inputs:
                  type: object
                  description: The template's inputs, by key.
            example:
              inputs:
                query: dentist
                areas:
                  - Lekki, Lagos
      responses:
        '200':
          description: The estimate.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  credits:
                    type:
                      - number
                      - 'null'
                    description: >-
                      Credits the run should cost. Null when it can't be known
                      in advance.
                  note:
                    type:
                      - string
                      - 'null'
                    description: >-
                      What can add to the estimate, such as AI tokens or a
                      second step.
                  pages:
                    type:
                      - integer
                      - 'null'
                    description: Pages the run reads.
        '404':
          description: No template with this slug.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Some inputs need fixing. `errors` lists each field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidInputError'
      security: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
      required:
        - status
        - message
    InvalidInputError:
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        code:
          type: string
          enum:
            - INVALID_INPUT
        message:
          type: string
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              message:
                type: string
          description: One entry per field that needs fixing.
  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.