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

# Update the configuration

> Updates the configuration.

The configuration is a list of configuration objects for each index. To configure Advanced Personalization for an index, create a new configuration object for the index.

**Required ACL:** `search`, `browse`, `recommendation`


## OpenAPI

````yaml specs/advanced-personalization.yml put /2/config
openapi: 3.1.0
info:
  title: Advanced Personalization API
  summary: >-
    The Advanced Personalization API lets you access user profiles built based
    on the behavior of your users on your website or app
  description: >
    ## Client libraries


    Use Algolia's API clients and libraries to reliably integrate Algolia's APIs
    with your apps.

    The official API clients are covered by Algolia's [Service Level
    Agreement](https://www.algolia.com/policies/sla).


    For more information, see [Algolia's
    ecosystem](https://www.algolia.com/doc/libraries).


    ## Base URLs


    The Advanced Personalization API can be reached from multiple domains, each
    specific to a region.


    - `https://ai-personalization.eu.algolia.com`

    - `https://ai-personalization.us.algolia.com`


    Use the URL that matches your [analytics
    region](https://dashboard.algolia.com/account/infrastructure/analytics).


    **All requests must use HTTPS.**


    ## Authentication


    Add these headers to authenticate requests:


    - `x-algolia-application-id`. Your Algolia application ID.

    - `x-algolia-api-key`. An API key with the `search`, `browse` and
    `recommendation` ACL permissions.


    You can find your application ID and API key in the [Algolia
    dashboard](https://dashboard.algolia.com/account/api-keys).


    ## Request format


    Request bodies must be JSON objects.


    ## Response status and errors


    The Advanced Personalization API returns JSON responses.

    Since JSON doesn't guarantee any specific ordering, don't rely on the order
    of attributes in the API response.


    Successful responses return `2xx` statuses. Client errors return `4xx`
    statuses. Server errors return `5xx` statuses.

    Error responses have a `message` property with more information.


    ## Rate limiting


    When making requests to the Advanced Personalization API, you are limited to
    500 API calls per minute per application.


    The following headers provide information about your current limit:


    - `x-ratelimit-limit`: The number of requests allowed every 60 seconds.

    - `x-ratelimit-remaining`: The number of requests remaining in the current
    60 second period.

    - `x-ratelimit-reset`: Timestamp when the next time period starts, measured
    in seconds since the Unix epoch.


    ## Version


    The current version of the Advanced Personalization API is version 2,
    indicated by the `/2/` in each endpoint's URL.
  version: 2.0.0
servers:
  - url: https://ai-personalization.{region}.algolia.com
    variables:
      region:
        description: >
          Use the URL that matches your [analytics
          region](https://dashboard.algolia.com/account/infrastructure/analytics).
        enum:
          - eu
          - us
        default: eu
security:
  - appId: []
    apiKey: []
tags:
  - name: config
    x-displayName: Configuration
    description: >
      Manage your Advanced Personalization configuration.


      The configuration defines the indices, facet attributes and events that
      describe your user's 

      behaviour on your website or app. It helps Advanced Personalization
      determine how personalization should affect the search results.
  - name: users
    x-displayName: Users
    description: >
      Manage user profiles generated by Advanced Personalization.


      User profiles contain the affinities each user has for the different
      facets in your index.
    externalDocs:
      url: >-
        https://www.algolia.com/doc/guides/personalization/ai-personalization/what-is-ai-personalization/concepts/user-profiles
      description: User profiles.
externalDocs:
  url: >-
    https://www.algolia.com/doc/guides/personalization/ai-personalization/what-is-ai-personalization
  description: What is Advanced Personalization.
paths:
  /2/config:
    put:
      tags:
        - config
      summary: Update the configuration
      description: >
        Updates the configuration.


        The configuration is a list of configuration objects for each index. To
        configure Advanced Personalization for an index, create a new
        configuration object for the index.
      operationId: putConfig
      requestBody:
        required: true
        content:
          application/json:
            schema:
              title: configurationParameters
              type: object
              properties:
                features:
                  $ref: '#/components/schemas/features'
                indices:
                  type: array
                  items:
                    title: configurationParametersObject
                    type: object
                    properties:
                      affinities:
                        type: array
                        items:
                          type: string
                      index:
                        type: string
                      source:
                        title: source
                        type: object
                        properties:
                          type:
                            $ref: '#/components/schemas/sourceType'
                          events:
                            $ref: '#/components/schemas/events'
                        required:
                          - type
                  required:
                    - index
                    - affinities
                    - source
                personalizationReRanking:
                  $ref: '#/components/schemas/personalizationReRanking'
                profileType:
                  $ref: '#/components/schemas/profileType'
              required:
                - indices
                - personalizationReRanking
                - profileType
                - features
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                title: putConfigResponse
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/issue'
                  message:
                    type: string
                  status:
                    type: number
                  warnings:
                    type: array
                    items:
                      $ref: '#/components/schemas/issue'
                required:
                  - status
                  - errors
                  - warnings
                  - message
        '400':
          $ref: '#/components/responses/BadRequest-2'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/FeatureNotEnabled-2'
        '500':
          $ref: '#/components/responses/InternalServerError'
      x-codeSamples:
        - lang: javascript
          label: JavaScript
          source: >-
            // Initialize the client

            // Replace 'eu' with your Algolia Application Region

            const client =
            advancedPersonalizationClient('ALGOLIA_APPLICATION_ID',
            'ALGOLIA_API_KEY', 'eu');


            // Call the API

            const response = await client.putConfig({
              indices: [],
              personalizationReRanking: 'maximum',
              profileType: 'basic',
              features: { realtime: { enabled: false } },
            });



            // print the response

            console.log(response);
        - lang: cURL
          label: curl
          source: |-
            curl --request PUT \
              --url https://ai-personalization.eu.algolia.com/2/config \
              --header 'accept: application/json' \
              --header 'content-type: application/json' \
              --header 'x-algolia-api-key: ALGOLIA_API_KEY' \
              --header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
              --data '
            {
              "indices": [
                {
                  "index": "lorem",
                  "affinities": [
                    "lorem"
                  ],
                  "source": {
                    "type": "insights",
                    "events": {
                      "viewDetails": [
                        {
                          "type": "view",
                          "subtype": "addToCart",
                          "name": "lorem"
                        }
                      ],
                      "viewListing": [
                        {
                          "type": "view",
                          "subtype": "addToCart",
                          "name": "lorem"
                        }
                      ],
                      "addToCart": [
                        {
                          "type": "view",
                          "subtype": "addToCart",
                          "name": "lorem"
                        }
                      ],
                      "purchase": [
                        {
                          "type": "view",
                          "subtype": "addToCart",
                          "name": "lorem"
                        }
                      ]
                    }
                  }
                }
              ],
              "personalizationReRanking": "none",
              "profileType": "basic",
              "features": {
                "realtime": {
                  "enabled": true
                }
              }
            }
            '
components:
  schemas:
    features:
      type: object
      properties:
        realtime:
          $ref: '#/components/schemas/realtime'
    sourceType:
      title: type
      type: string
      enum:
        - insights
    events:
      type: object
      properties:
        addToCart:
          type: array
          items:
            $ref: '#/components/schemas/event'
        purchase:
          type: array
          items:
            $ref: '#/components/schemas/event'
        viewDetails:
          type: array
          items:
            $ref: '#/components/schemas/event'
        viewListing:
          type: array
          items:
            $ref: '#/components/schemas/event'
      required:
        - viewDetails
        - viewListing
        - addToCart
        - purchase
    personalizationReRanking:
      type: string
      description: The impact that personalization has on the re-ranking of search results.
      enum:
        - none
        - low
        - medium
        - high
        - maximum
    profileType:
      type: string
      enum:
        - basic
      description: >
        The type of user profiles to generate.


        Basic profiles are based on past behaviors, ensuring search results
        align with previous interests.
    issue:
      type: object
      description: >-
        An issue is either an 'error' or a 'warning' that is generated by the
        validator.
      properties:
        code:
          type: string
        index:
          type: string
        message:
          type: string
      required:
        - code
        - index
        - message
    realtime:
      type: object
      properties:
        enabled:
          type: boolean
          description: Whether the realtime personalization feature is enabled.
    event:
      type: object
      properties:
        name:
          type: string
        type:
          $ref: '#/components/schemas/eventType'
        subtype:
          $ref: '#/components/schemas/subtype'
      required:
        - type
        - name
    ErrorResponses_badRequest:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/ErrorMessages_badRequest'
        status:
          $ref: '#/components/schemas/badRequest'
    ErrorResponses_unauthorized:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/ErrorMessages_unauthorized'
        status:
          $ref: '#/components/schemas/unauthorized'
    ErrorResponses_featureNotEnabled:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/featureNotEnabled'
        status:
          $ref: '#/components/schemas/paymentRequired'
    ErrorResponses_internalServerError:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/ErrorMessages_internalServerError'
        status:
          $ref: '#/components/schemas/internalServerError'
    eventType:
      type: string
      enum:
        - view
        - click
        - conversion
    subtype:
      type: string
      enum:
        - addToCart
        - purchase
    ErrorMessages_badRequest:
      type: string
      description: Details about the response, such as error messages.
      enum:
        - Invalid request body
    badRequest:
      type: integer
      description: HTTP status code for a bad request error.
      enum:
        - 400
    ErrorMessages_unauthorized:
      type: string
      description: Details about the response, such as error messages.
      enum:
        - Unauthorized
    unauthorized:
      type: integer
      description: HTTP status code for an authorization error.
      enum:
        - 401
    featureNotEnabled:
      type: string
      description: Details about the response, such as error messages.
      enum:
        - >-
          Predictive profiles are not allowed for this app. Please contact
          support to upgrade your plan: https://support.algolia.com/
        - >-
          Realtime Personalization is not allowed for this app. Please contact
          support to upgrade your plan: https://support.algolia.com/
    paymentRequired:
      type: integer
      description: HTTP status code for a payment required error.
      enum:
        - 402
    ErrorMessages_internalServerError:
      type: string
      description: Details about the response, such as error messages.
      enum:
        - Internal Server Error
    internalServerError:
      type: integer
      description: HTTP status code for an internal server error.
      enum:
        - 500
  responses:
    BadRequest-2:
      description: Bad request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponses_badRequest'
    Unauthorized:
      description: Not authorized to access this resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponses_unauthorized'
    FeatureNotEnabled-2:
      description: Feature not enabled.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponses_featureNotEnabled'
    InternalServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponses_internalServerError'
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: x-algolia-application-id
      description: Your Algolia application ID.
    apiKey:
      type: apiKey
      in: header
      name: x-algolia-api-key
      description: >
        Your Algolia API key with the necessary permissions to make the request.

        Permissions are controlled through access control lists (ACL) and access
        restrictions.

        The required ACL to make a request is listed in each endpoint's
        reference.

````