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

# Logs a redirection

> Logs a "redirection triggered" event in stats logs.



## OpenAPI

````yaml /openapi/search-v6.yaml put /6/{hashid}/stats/redirect
openapi: 3.0.0
info:
  title: Search API
  contact:
    name: Doofinder Support
    url: https://docs.doofinder.com/
  version: '6.0'
  description: >
    # Introduction

    Search API allows you to perform the search requests you can do on your
    search

    engines using the doofinder layer, directly from your code.

    # Basics

    ## Endpoint

    All requests should be done with `https` protocol in our api location.

    `https://{search_zone}-search.doofinder.com`

    where `{search_zone}` depends on your location, is the geographic zone your
    search engine is located at.

    i.e.: eu1. Also, indicates which host to use in your API calls.

    ## Authentication

    The authentication method for search API requires an api key that could be
    obtained in our

    [management control panel](https://admin.doofinder.com).

    You can generate it in your user account -> Api Keys.

    Example of the generated API Key:

    `eu1-ab46030xza33960aac71a10248489b6c26172f07`

    ### API Token

    You could authenticate with the previous API key in header as a Token. The
    correct way to authenticate is

    to send a HTTP Header with the name `Authorization` and the value `Token
    <API Key>`

    For example, for the key shown above:

    `Authorization: Token eu1-ab46030xza33960aac71a10248489b6c26172f07`

    ## Client IP

    If you're calling this API directly from your own backend, rather than
    through Doofinder's

    JS layer, forward your end user's real IP address on every request, using
    one of:

    - `X-Real-IP`

    - `X-Forwarded-For`

    Without one of these headers, every request from your integration will
    appear to come from

    your server's single static IP address. Repeated requests from that one
    static IP can be

    flagged as bot traffic, which silently drops the affected search and
    click/session stats

    from your reports. It also skews any geographic breakdown in your stats,
    since it will be

    based on your server's location instead of your end users' locations.

    ## Conventions

    Along most of the code samples you will find placeholders for some common
    variable values. They are:

    - `{hashid}`: The search engine's unique id. i.e.:
    d8fdeab7fce96a19d3fc7b0ca7a1e98b

    - `{token}`: Your personal authentication token obtained in the control
    panel.

    - `{index}`: The index of the data you're searching at. i.e.: product

    - `{id}`: Unique identification of a resource. i.e.: 1234 or HVIUYC
  termsOfService: https://www.doofinder.com/es/terms-and-conditions
  x-logo:
    url: https://admin.doofinder.com/images/logo.svg
    backgroundColor: '#33268C'
    altText: Doofinder Search Engine
servers:
  - url: https://{search_zone}-search.doofinder.com
    variables:
      search_zone:
        enum:
          - eu1
          - us1
          - ap1
        default: eu1
  - url: /
security:
  - api_token: []
tags:
  - name: Search
    description: Search operations.
  - name: Session & Events
    description: Stats operations.
paths:
  /6/{hashid}/stats/redirect:
    put:
      tags:
        - Session & Events
      summary: Logs a redirection
      description: Logs a "redirection triggered" event in stats logs.
      operationId: redirect_stats
      parameters:
        - $ref: '#/components/parameters/hashid'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogRedirectionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsResponse'
        '400':
          description: >-
            Bad Request — missing required fields (session_id, id) or redirect
            id is not numeric.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing_fields:
                  summary: Required fields missing
                  value:
                    error: '[session_id, id] fields are missing'
                invalid_id:
                  summary: Redirect id is not numeric
                  value:
                    error: Invalid redirect id
        '403':
          description: >-
            Forbidden — missing or invalid API token, client IP is blocked, or
            CORS `Origin` not allowed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Missing or invalid API token
                  value:
                    error: forbidden
                banned_ip:
                  summary: Client IP is blocked
                  value:
                    error: banned ip
components:
  parameters:
    hashid:
      name: hashid
      in: path
      description: Unique id of a search engine.
      required: true
      schema:
        type: string
  schemas:
    LogRedirectionRequest:
      type: object
      properties:
        id:
          type: string
          description: The id of the redirection triggered
        query:
          $ref: '#/components/schemas/query'
        session_id:
          $ref: '#/components/schemas/session_id'
      required:
        - id
        - session_id
    StatsResponse:
      title: Stats Response
      description: Response returned over register stat operation.
      type: object
      properties:
        status:
          description: Result of the stats request. i.e. 'registered'
          type: string
      example:
        status: registered
    ErrorResponse:
      type: object
      description: Standard error response returned on all non-200 outcomes.
      properties:
        error:
          type: string
          description: Human-readable error message.
      required:
        - error
    query:
      type: string
      description: The search query that led to this
    session_id:
      type: string
      description: Identifier of search session
      maxLength: 32
  securitySchemes:
    api_token:
      type: apiKey
      name: Authorization
      in: header
      description: >
        Doofinder API key. The `Token` prefix is part of the header value, so
        enter it too — the field is sent verbatim as:

            Authorization: Token <api_key>
      x-default: Token <your_api_key>

````

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