# Batch insert synonyms

- Operation ID: `BatchSynonyms`
- HTTP method: `POST`
- Path: `/search/v2/indices/{indexId}/synonyms/batch`
- [Human-readable API reference](https://hub.synerise.com/api-reference/ai-search#tag/Synonyms/operation/BatchSynonyms)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /search/v2/indices/{indexId}/synonyms/batch:
    post:
      summary: Batch insert synonyms
      description: |
        Insert multiple synonyms into an index at once.

        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>

        **API key permission required:** `SYNONYMS_SEARCH_CREATE`

        **User role permission required:** `assets_search: create`
      operationId: BatchSynonyms
      tags:
        - Synonyms
      security:
        - JWT: []
      parameters:
        - name: source
          in: query
          required: false
          description: Source to assign to imported synonyms
          schema:
            allOf:
              - type: string
                description: Origin of the synonym
                enum:
                  - User
                  - Agent
                  - Import
                default: User
              - default: Import
        - in: path
          name: indexId
          required: true
          description: Index identifier
          schema:
            type: string
            format: uuid
      requestBody:
        description: |
          
          The CSV has three columns: 
          - `word`: the phrase to replace with a synonym
          - `synonyms`: the synonyms of the word (if more than one, the list is comma-separated and enclosed with `""`)
          - `type`: the relation type:
            - `oneway`: when the word is searched, the results show the results as if the synonyms were searched. Searching for the synonyms does NOT return results for the word or the other synonyms.
            - `synonyms`: the `word` column is empty, all phrases in `synonym` return results for every other phrase in the list.
        required: true
        content:
          text/csv:
            schema:
              type: object
              properties:
                word:
                  type: string
                  description: "The phrase that the synonym relates to. If `type: synonyms`, do not send this value."
                synonyms:
                  type: array
                  description: A list of synonyms
                  items:
                    type: string
                type:
                  type: string
                  description: |
                    Type of the synonym.

                      - `oneway`: when the word is searched, the results show the results as if the synonyms were searched. Searching for the synonyms does NOT return results for the word or the other synonyms.
                      - `synonyms`: the `word` column is empty, all phrases in `synonym` return results for every other phrase in the list.
                  enum:
                    - oneway
                    - synonyms
                  default: oneway
            example: |
              word,synonyms,type
              dog,"doggy,puppy",oneway
              small horse,pony,oneway
              ,"cat,kitten,kitty,tabby cat",synonyms
          multipart/form-data:
            schema:
              type: object
              properties:
                synonyms:
                  type: string
                  format: binary
                  description: Uploaded CSV file to be used in synonyms update
      responses:
        "200":
          description: Summary of batch insertion
          content:
            application/json:
              schema:
                type: object
                properties:
                  attemptedInserts:
                    type: integer
                    description: The number of attempted insertions
                  actualInserts:
                    type: integer
                    description: The number of successful insertions
                  errors:
                    type: array
                    description: A list of errors
                    items:
                      type: string
        "500":
          description: Some error occurred
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  status:
                    type: integer
                    description: Status code
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  path:
                    type: string
                    description: URL of the requested resource
                required:
                  - timestamp
                  - status
                  - message
      x-snr-doc-urls:
        - /api-reference/ai-search#tag/Synonyms/operation/BatchSynonyms
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Synonyms
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
