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

# Create temporary index

> Creates a new empty temporary index for the same index name. There can
not be two temporary indices at the same time, so any request made to
this endpoint when there is one created will fail. Creating a temporary
index also sets a lock preventing any changes on the search engine until
the temporary index is deleted.




## OpenAPI

````yaml /openapi/management-v2.yaml post /api/v2/search_engines/{hashid}/indices/{name}/temp/
openapi: 3.0.0
info:
  title: Management API
  contact:
    name: Management API Support
    url: https://docs.doofinder.com/
  version: '2.0'
  x-logo:
    url: https://admin.doofinder.com/images/logo.svg
    backgroundColor: '#33268C'
    altText: Management API Search Engine
  description: >
    # Introduction


    Management API allows you to perform some of the administrative tasks you
    can do on your search

    engines using the Admin control panel, directly from your code.


    # Basics


    ## Endpoint


    All requests should be done via `https` to the right endpoint:


    ```

    https://{search-zone}-api.doofinder.com

    ```


    Where `{search-zone}` is the code of the datacenter where your search
    engines are located.


    For instance:


    ```

    https://eu1-api.doofinder.com

    https://us1-api.doofinder.com

    ```


    ## Authentication


    To authenticate you need an API key. If you don't have one you can generate
    it in the Admin by going to your Account and then to API Keys,
    [here](https://admin.doofinder.com/admin/account/api).


    A valid API key looks like this:


    ```

    ab46030xza33960aac71a10248489b6c26172f07

    ```


    ### API Token


    You can authenticate with the previous API key. The correct way to
    authenticate is to send a HTTP Header with the name `Authorization` and the
    value `Token {api-key}`.


    I.e.:


    ```

    Authorization: Token ab46030xza33960aac71a10248489b6c26172f07

    ```


    ### JWT Token


    If you prefer you can authenticate with a [JSON Web Token](https://jwt.io).
    The token must be signed with an API management key and there are some
    claims required in the JWT payload. These claims are:

      * `iat` (issued at): Creation datetime timestamp, i.e. the moment when the JWT was created.

      * `exp` (expiration time): Expiration datetime timestamp, i.e. the moment when the JWT is going to expire and will no longer be valid. The time span between issued and expiration dates must be shorter than a week.

      * `name`: Your user code. It is your unique identifier as doofinder user. You can find this code in your profile page in the administration panel.

    To authenticate using JWT you must send a HTTP header with the name
    `Authorization` and the value `Bearer {JWT-token}`.


    I.e.:


    ```

    Authorization: Bearer
    eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCIsImlhdCI6MTUxNjIzOTAyMn0.QX_3HF-T2-vlvzGDbAzZyc1Cd-J9qROSes3bxlgB4uk

    ```


    ## 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. e.g.: d8fdeab7fce96a19d3fc7b0ca7a1e98b.

      * `{index}`: When storing items, they're always stored under a certain _index_. e.g.: product.

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

    ## Api limits


    ### Requests rate


    The API has a limit of 20 requests per second. If you do more than that, the
    next requests will get a `429 Too Many Requests` error. There is no penalty
    associated to that error, but you must wait one second before attempting
    more requests.


    ### Body size


    The body size for requests with data sending (eg: POST or PUT requests) has
    a limit of 8MB. If you do a request with a request body bigger than 8 MB,
    the response will be `413 Payload Too Large`. This is important mostly for
    batch calls like batch create items.


    ### Batch size


    Bulk item operations (create, update, delete) accept a maximum of **100
    items per request**. Requests with more than 100 items will be rejected with
    a `422 Unprocessable Entity` error. Split larger payloads into batches of up
    to 100 items.


    # Objects


    ## Search Engines


    A search engine is a collection of indices where data is stored. It has some
    properties like name, language, and some other configuration options that
    are shared among all of its indices.


    Each search engine is uniquely identified by its `hashid` which is an
    auto-generated string.


    Search engines have a _"process"_ operation which takes items from all its
    data sources and insert them into their indices. This operation has a zero
    downtime, you can still search into indices while processing.


    ## Indices


    Indices are collections of items, the same way a search engine is a
    collection of indices. An index also has a set of data sources which usually
    are urls where the items for indexing are taken from.


    If you need to reindex a whole index you can create a temporary index. The
    mission of a temporary index is indexing items while you can still search
    the main index, having zero downtime.


    ## Data Sources


    Data sources are indices items sources. When you process a search engine, we
    take the items from its data sources and "insert" them into the indices. You
    do not need any data source if you index items only by API.


    ## Items


    Items are objects stored in an index. Those are the elements you search for
    when doing query to a search engine. They may have different schemas
    depending on their index **preset**. For instance, a `product` item will
    have a price, category, etc.


    In case you want to group items as a product with variants, you have to add
    these two fields:


    * `group_id`: All the items with the same group id will be members of the
    group. Could be the parent id or just an independent id.


    * `group_leader`: Boolean indicating if the item is the leader of the
    variant group, which will be the item shown among its group in the search
    results. It is not mandatory if there is no item leader.


    You could index the items in any order because the grouping feature is made
    in search phase.

    An example of request payload would be:


    ```

    [

      {
          "title": "Item Variant 1",
          "link": "http://www.example.com/img/variant1.png",
          "id": "1",
          "df_manual_boost": 1,
          "categories": [...],
          "group_id": "99",
          "group_leader": true
      },

      {
          "title": "Item Variant 2",
          "link": "http://www.example.com/img/variant2.png",
          "id": "2",
          "df_manual_boost": 1,
          "categories": [...],
          "group_id": "99",
          "group_leader": false
      },

    ]

    ```


    ### Items transformations


    When your Index has `product` preset, some defaults are added to your item
    at creation. For instance

      * `categories` field if not provided, would be a empty list at response `[]`.
      * `best_price` would get the min value between `price` and `sale_price` item fields if present, if not, would be `null`.
      Fields `price` and `sale_price` should be a number like: 15.56.
      If you want to update `best_price`, `price` and `sale_price` should be present.

    When your Index has `generic` preset, this defaults will not be applied.
  termsOfService: https://www.doofinder.com/en/terms-and-conditions
servers:
  - url: https://{search_zone}-api.doofinder.com
    variables:
      search_zone:
        enum:
          - eu1
          - us1
          - ap1
        default: eu1
  - url: /
security:
  - api_token: []
  - jwt_token: []
tags:
  - name: Search Engines
    description: >-
      All search engines CRUD operations, including handling data sources
      processing.
  - name: Indices
    description: All indices and temporary indices CRUD operations.
  - name: Items
    description: >-
      Handling content of indices. Allows to retrieve and update the items of an
      index.
  - name: Stats
    description: Provides statistical information about your search engines.
    externalDocs:
      url: https://docs.doofinder.com/api/management/v2/stats/
paths:
  /api/v2/search_engines/{hashid}/indices/{name}/temp/:
    post:
      tags:
        - Indices
      summary: Create temporary index
      description: |
        Creates a new empty temporary index for the same index name. There can
        not be two temporary indices at the same time, so any request made to
        this endpoint when there is one created will fail. Creating a temporary
        index also sets a lock preventing any changes on the search engine until
        the temporary index is deleted.
      operationId: temporary_index_create
      parameters:
        - $ref: '#/components/parameters/searchengine_hashid'
        - $ref: '#/components/parameters/index_name'
      responses:
        '201':
          description: Temporary index created.
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                status: OK
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/ConflictTooManyTemp'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    searchengine_hashid:
      name: hashid
      in: path
      description: Unique id of a search engine.
      required: true
      schema:
        type: string
        pattern: ^[a-f0-9]{32}$
    index_name:
      name: name
      in: path
      description: Name of an index.
      required: true
      schema:
        type: string
        pattern: ^[a-z][a-z0-9_]*$
  responses:
    BadRequest:
      description: Bad Request — invalid or missing parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: bad_params
              message: Bad parameters error
              details:
                - name: language
                  fields:
                    - language
                  reason: is invalid
    Unauthorized:
      description: Unauthorized — no valid API token provided.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: not_authenticated
              message: Authentication required
    Forbidden:
      description: Forbidden — token is valid but does not have access to this resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: access_denied
              message: Access denied
    NotFound:
      description: Not Found — the requested resource does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: not_found
              message: Not found
    ConflictTooManyTemp:
      description: Conflict — a temporary index already exists for this index.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: too_many_temporary
              message: A temporary index already exists for this index
    TooManyRequests:
      description: Too Many Requests — rate limit exceeded; back off and retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: too_many_requests
              message: Too many requests
    InternalServerError:
      description: Internal Server Error — unexpected backend failure.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ManagementError'
          example:
            error:
              code: internal_error
              message: Internal server error
  schemas:
    ManagementError:
      type: object
      description: Standard error wrapper for all Management API error responses.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code.
              example: not_found
            message:
              type: string
              description: Human-readable error description.
              example: Not found
            details:
              type: array
              description: >-
                Optional list of per-field validation details (present on
                bad_params and errors_in_fields).
              items:
                $ref: '#/components/schemas/ManagementErrorDetail'
          required:
            - code
            - message
      required:
        - error
    ManagementErrorDetail:
      type: object
      description: Details about a specific validation failure on a field.
      properties:
        name:
          type: string
          description: Field name.
          example: language
        fields:
          type: array
          items:
            type: string
          description: Affected field names.
          example:
            - language
        reason:
          type: string
          description: Validation failure reason.
          example: is invalid
  securitySchemes:
    api_token:
      type: apiKey
      description: |
        Doofinder API key. Pass it as:
        Authorization: Token <api_key>
      name: Authorization
      in: header
    jwt_token:
      type: apiKey
      description: |
        JWT Bearer token. Sign a JWT with your API key (HS256) and pass it as:
        Authorization: Bearer <jwt_token>
      name: Authorization
      in: header

````