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

# Keywords

export const EndpointBadge = ({method = "GET", children}) => {
  const METHOD_STYLES = {
    GET: {
      bg: "mint-bg-[#2AB673]"
    },
    POST: {
      bg: "mint-bg-[#3064E3]"
    },
    PUT: {
      bg: "mint-bg-[#C28C30]"
    },
    PATCH: {
      bg: "mint-bg-[#DA622B]"
    },
    DELETE: {
      bg: "mint-bg-[#CB3A32]"
    },
    API: {
      bg: "mint-bg-black"
    }
  };
  const key = method.toUpperCase();
  const styles = METHOD_STYLES[key] ?? METHOD_STYLES.API;
  return <div className="relative mt-7">
      <span className={`absolute -top-2 -left-2 z-10 ${styles.bg} text-white px-2.5 py-0.5 rounded-full text-xs font-bold tracking-wide`}>
        {key}
      </span>
      {children}
    </div>;
};

<Note>
  Shoppers browsing through the retailer's search page may utilize search for phrases associated with line item products where the line item may not be allowed to search on that page. Similar to this scenario, the shopper can also enter search phrases that align with products permitted to serve on a page.

  The keyword API endpoint allows you to control your Onsite Sponsored Products line item by providing visibility to users what keywords are applied to line items, and also allows for users to determine which keyword to target positively or negatively. The endpoint can also provide keyword bidding capabilities to optimize line items based on relevant keywords.

  Check out the [**Onsite Sponsored Products**](/retail-media/v2025.10/docs/onsite-sponsored-products) page for a complete summary of Criteo's keyword service.
</Note>

## Endpoints

<table>
  <thead>
    <tr>
      <th>
        <p>
          Verb
        </p>
      </th>

      <th>
        <p>
          Endpoint
        </p>
      </th>

      <th>
        <p>
          Description
        </p>
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <p>
          <b>
            GET
          </b>
        </p>
      </td>

      <td>
        <p>
          <code>
            /line-items/\{lineItemId}/keywords
          </code>
        </p>
      </td>

      <td>
        <p>
          Retrieve a set of positive and negative keywords for a line item
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <b>
            GET
          </b>
        </p>
      </td>

      <td>
        <p>
          <code>
            /line-items/\{lineItemId}/keywords/recommended
          </code>
        </p>
      </td>

      <td>
        <p>
          Retrieve a collection of recommended keywords for a line item
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <b>
            POST
          </b>
        </p>
      </td>

      <td>
        <p>
          <code>
            /line-items/\{lineItemId}/keywords/add-remove
          </code>
        </p>
      </td>

      <td>
        <p>
          Add or remove keywords from a line item
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <b>
            POST
          </b>
        </p>
      </td>

      <td>
        <p>
          <code>
            /line-items/\{lineItemId}/keywords/set-bid
          </code>
        </p>
      </td>

      <td>
        <p>
          Set a bid override at keyword level
        </p>
      </td>
    </tr>
  </tbody>
</table>

***

## Keyword Attributes

<table>
  <thead>
    <tr>
      <th>
        <p>
          Attribute
        </p>
      </th>

      <th>
        <p>
          Data Type
        </p>
      </th>

      <th>
        <p>
          Description
        </p>
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <p>
          <code>
            id
          </code>

          <span>\*</span>
        </p>
      </td>

      <td>
        <p>
          string
        </p>
      </td>

      <td>
        <p>
          <a href="/retail-media/v2025.10/docs/line-items">
            Line Item
          </a>

          ID, generated internally by Criteo
        </p>

        <p>
          Accepted values: string of int64
        </p>

        <p>
          Writeable? N / Nullable? N
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            keywords
          </code>

          <span>\*</span>
        </p>
      </td>

      <td>
        <p>
          object
        </p>
      </td>

      <td>
        <p>
          Keywords structure, indexed by normalized keyword phrases each of them containing structure of:
        </p>

        <ul>
          <li>
            <code>
              matchType
            </code>
          </li>

          <li>
            <code>
              bid
            </code>
          </li>

          <li>
            <code>
              inputKeywords
            </code>
          </li>

          <li>
            <code>
              reviewState
            </code>
          </li>

          <li>
            <code>
              createdAt
            </code>
          </li>

          <li>
            <code>
              updatedAt
            </code>
          </li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            matchType
          </code>

          <span>\*</span>
        </p>
      </td>

      <td>
        <p>
          enum
        </p>
      </td>

      <td>
        <p>
          Matching algorithm type to be used when comparing this keyword with shopper search phrases.
        </p>

        <p>
          Accepted values:
        </p>

        <ul>
          <li>
            <code>
              PositiveExactMatch
            </code>

            : normalized keyword is an exact match for the normalized search phrase bid
          </li>

          <li>
            <code>
              NegativeExactMatch
            </code>

            : normalized keyword is an exact match for the normalized search phrase do not bid
          </li>

          <li>
            <code>
              NegativeBroadMatch
            </code>

            : normalized keyword is a substring of the normalized search phrase do not bid
          </li>
        </ul>

        <p>
          Default:

          <code>
            PositiveExactMatch
          </code>
        </p>

        <p>
          Writeable? N / Nullable? N
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            reviewState
          </code>
        </p>
      </td>

      <td>
        <p>
          enum
        </p>
      </td>

      <td>
        <p>
          Status of Keyword review, only applicable for

          <code>
            PositiveExactMatch
          </code>

          match type keywords.
        </p>

        <p>
          Keywords not reviewed by the automatic keyword service will be reviewed and approved by the retailer.
        </p>

        <p>
          Accepted values:
        </p>

        <ul>
          <li>
            <code>
              InReview
            </code>

            : keyword has been submitted manually, and the review is still pending
          </li>

          <li>
            <code>
              Approved
            </code>

            : keyword was approved manually
          </li>

          <li>
            <code>
              AutoApproved
            </code>

            : keyword was approved automatically
          </li>

          <li>
            <code>
              Rejected
            </code>

            : keyword was rejected manually
          </li>

          <li>
            <code>
              AutoRejected
            </code>

            : keyword was rejected automatically
          </li>

          <li>
            <code>
              Recommended
            </code>

            : keyword was recommended by our keyword model
          </li>
        </ul>

        <p>
          Default:

          <code>
            InReview
          </code>
        </p>

        <p>
          Writeable? N / Nullable? N
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            bid
          </code>
        </p>
      </td>

      <td>
        <p>
          decimal
        </p>
      </td>

      <td>
        <p>
          The bid override for the positive keyword. The keyword will use the default line item bid if the value is

          <code>
            null
          </code>

          . The currency of the bid is the default currency for the retailer. The bid can be applied to both manual keywords and recommended keywords.
        </p>

        <p>
          Accepted values: retailer's

          <code>
            minBid
          </code>

          ≤

          <code>
            bid
          </code>

          ≤ line-item's

          <code>
            maxBid
          </code>

          , available in the endpoints detailed in

          <a href="/retail-media/v2025.10/docs/catalog-endpoints">
            Catalog Endpoints
          </a>

          and

          <a href="/retail-media/v2025.10/docs/onsite-display-line-itemsv2">
            Onsite Display Line Items
          </a>

          , respectively
        </p>

        <p>
          Default:

          <code>
            null
          </code>
        </p>

        <p>
          Writeable? Y / Nullable? Y
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            isDeleted
          </code>
        </p>
      </td>

      <td>
        <p>
          boolean
        </p>
      </td>

      <td>
        <p>
          Control flag to add or remove the keyword from the line-item
        </p>

        <p>
          Accepted values:

          <code>
            true
          </code>

          /

          <code>
            false
          </code>
        </p>

        <p>
          Writeable? N / Nullable? N
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            inputKeywords
          </code>

          <span>\*</span>
        </p>
      </td>

      <td>
        <p>
          object
        </p>
      </td>

      <td>
        <p>
          Keywords structure associated with line-item containing normalized keyword phrases and organized by match type.
        </p>

        <p>
          Parameters:
        </p>

        <ul>
          <li>
            <code>
              positiveExact
            </code>

            : list of supplied positive exact phrases
          </li>

          <li>
            <code>
              negativeExact
            </code>

            : list of supplied negative exact phrases
          </li>

          <li>
            <code>
              negativeBroad
            </code>

            : list of supplied negative broad phrases
          </li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            phrase
          </code>
        </p>
      </td>

      <td>
        <p>
          string
        </p>
      </td>

      <td>
        <p>
          Raw text of the keyword to be added or removed
        </p>

        <p>
          Accepted values: up to 255-chars string
        </p>

        <p>
          Writeable? Y / Nullable? N
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            createdAt
          </code>
        </p>
      </td>

      <td>
        <p>
          timestamp
        </p>
      </td>

      <td>
        <p>
          Timestamp when keyword was configured in the line-item (or recommended to line-item)
        </p>

        <p>
          Accepted values:

          <code>
            yyyy-mm-ddThh:mm:ss
          </code>

          (in

          <a href="https://en.wikipedia.org/wiki/ISO_8601">
            ISO-8601
          </a>

          )
        </p>

        <p>
          Writeable? N / Nullable? N
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          <code>
            updatedAt
          </code>
        </p>
      </td>

      <td>
        <p>
          timestamp
        </p>
      </td>

      <td>
        <p>
          Timestamp when keyword was last modified in the line-item (or recommended to line-item)
        </p>

        <p>
          Accepted values:

          <code>
            yyyy-mm-ddThh:mm:ss
          </code>

          (in

          <a href="https://en.wikipedia.org/wiki/ISO_8601">
            ISO-8601
          </a>

          )
        </p>

        <p>
          Writeable? N / Nullable? N
        </p>
      </td>
    </tr>
  </tbody>
</table>

*\*Required*

<Info>
  **Field Definitions**

  * **Writeable (Y/N)**: Indicates if the field can be modified in requests.
  * **Nullable (Y/N)**: Indicates if the field can accept null/empty values.
  * **Primary Key**: A unique, immutable identifier of the entity, generated internally by Criteo. Primary keys are typically ID fields (e.g., `retailerId`, `campaignId`, `lineItemId`) and are usually required in the URL path.
</Info>

***

## Get Keywords by Line Item

<EndpointBadge method="get">
  ```http theme={null}
  https://api.criteo.com/{version}/retail-media/line-items/{lineItemId}/keywords
  ```
</EndpointBadge>

**Sample Request**

<CodeGroup>
  ```bash cURL theme={null}
  curl -L -X GET "https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords" \
      -H "Authorization: Bearer <MY_ACCESS_TOKEN>" \
      -H "Accept: application/json"
  ```

  ```python Python theme={null}
  import http.client

  conn = http.client.HTTPSConnection("api.criteo.com")

  headers = {
      'Authorization': 'Bearer <MY_ACCESS_TOKEN>',
      'Accept': 'application/json'
  }

  conn.request("GET", "/{version}/retail-media/line-items/358669652976373760/keywords", headers=headers)

  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))
  ```

  ```java Java theme={null}
  OkHttpClient client = new OkHttpClient().newBuilder()
      .build();

  Request request = new Request.Builder()
      .url("https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords")
      .method("GET", null)
      .addHeader("Authorization", "Bearer <MY_ACCESS_TOKEN>")
      .addHeader("Accept", "application/json")
      .build();

  Response response = client.newCall(request).execute();
  ```

  ```php PHP theme={null}
  <?php
  require_once 'HTTP/Request2.php';
  $request = new HTTP_Request2();
  $request->setUrl('https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords');
  $request->setMethod(HTTP_Request2::METHOD_GET);
  $request->setConfig(array(
      'follow_redirects' => TRUE
  ));
  $request->setHeader(array(
      'Authorization' => 'Bearer <MY_ACCESS_TOKEN>',
      'Accept' => 'application/json'
  ));

  try {
      $response = $request->send();
      if ($response->getStatus() == 200) {
          echo $response->getBody();
      } else {
          echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase();
      }
  } catch(HTTP_Request2_Exception $e) {
      echo 'Error: ' . $e->getMessage();
  }
  ```
</CodeGroup>

**Sample Response**

```json expandable theme={null}
{
    "data": {
        "id": "358669652976373760",
        "type": "RetailMediaKeywordsModel",
        "attributes": {
            "keywords": {
                "vegetable": {
                    "matchType": "NegativeBroadMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [
                            "vegetable"
                        ],
                        "negativeExact": [],
                        "positiveExact": []
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "tomato": {
                    "matchType": "NegativeExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [
                            "tomatoes"
                        ],
                        "positiveExact": []
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "strawberry": {
                    "matchType": "NegativeExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [
                            "strawberry"
                        ],
                        "positiveExact": []
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "broccoli": {
                    "matchType": "NegativeExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [
                            "broccoli"
                        ],
                        "positiveExact": []
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "banana": {
                    "matchType": "NegativeExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [
                            "banana"
                        ],
                        "positiveExact": []
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "pasta": {
                    "reviewState": "Approved",
                    "matchType": "PositiveExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [],
                        "positiveExact": [
                            "pasta"
                        ]
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "milk": {
                    "reviewState": "Approved",
                    "matchType": "PositiveExactMatch",
                    "bid": 0.50,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [],
                        "positiveExact": [
                            "milk"
                        ]
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "juice": {
                    "reviewState": "Approved",
                    "matchType": "PositiveExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [],
                        "positiveExact": [
                            "juice"
                        ]
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "egg": {
                    "reviewState": "Approved",
                    "matchType": "PositiveExactMatch",
                    "bid": 0.50,
                    "inputKeywords": {
                        "negativeBroad": [],
                        "negativeExact": [],
                        "positiveExact": [
                            "eggs"
                        ]
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                },
                "fruit": {
                    "matchType": "NegativeBroadMatch",
                    "bid": null,
                    "inputKeywords": {
                        "negativeBroad": [
                            "fruits"
                        ],
                        "negativeExact": [],
                        "positiveExact": []
                    },
                    "createdAt": "2025-01-01T00:00:00",
                    "updatedAt": "2025-01-01T00:00:00"
                }
            }
        }
    },
    /* omitted if no errors */
    "errors": [],
    /* omitted if no warnings */
    "warnings": []
}
```

***

## Get Recommended Keywords by Line Item

This endpoint retrieves a collection of recommended keywords for a line item, created automatically by our keyword models.

<Note>
  **Only the top 100 keywords will be returned**

  Automatic recommended keywords can change day to day, as are determined based on click volumes by users on Retailer's environment. Although significant changes are not expected, it is possible that the long tail of the top 100 keywords change slightly
</Note>

<EndpointBadge method="get">
  ```http theme={null}
  https://api.criteo.com/{version}/retail-media/line-items/{lineItemId}/keywords/recommended
  ```
</EndpointBadge>

**Sample Request**

<CodeGroup>
  ```bash cURL theme={null}
  curl -L -X GET "https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/recommended" \
      -H "Authorization: Bearer <MY_ACCESS_TOKEN>" \
      -H "Accept: application/json"
  ```

  ```python Python theme={null}
  import http.client

  conn = http.client.HTTPSConnection("api.criteo.com")

  headers = {
      'Authorization': 'Bearer <MY_ACCESS_TOKEN>',
      'Accept': 'application/json'
  }

  conn.request("GET", "/{version}/retail-media/line-items/358669652976373760/keywords/recommended", headers=headers)

  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))
  ```

  ```java Java theme={null}
  OkHttpClient client = new OkHttpClient().newBuilder()
      .build();

  Request request = new Request.Builder()
      .url("https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/recommended")
      .method("GET", null)
      .addHeader("Authorization", "Bearer <MY_ACCESS_TOKEN>")
      .addHeader("Accept", "application/json")
      .build();

  Response response = client.newCall(request).execute();
  ```

  ```php PHP theme={null}
  <?php
  require_once 'HTTP/Request2.php';
  $request = new HTTP_Request2();
  $request->setUrl('https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/recommended');
  $request->setMethod(HTTP_Request2::METHOD_GET);
  $request->setConfig(array(
      'follow_redirects' => TRUE
  ));
  $request->setHeader(array(
      'Authorization' => 'Bearer <MY_ACCESS_TOKEN>',
      'Accept' => 'application/json'
  ));

  try {
      $response = $request->send();
      if ($response->getStatus() == 200) {
          echo $response->getBody();
      } else {
          echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase();
      }
  } catch(HTTP_Request2_Exception $e) {
      echo 'Error: ' . $e->getMessage();
  }
  ```
</CodeGroup>

**Sample Response**

```json expandable theme={null}
{
    "data": {
        "type": "RecommendedKeywords",
        "attributes": {
            "keywords": {
                "bar sound": {
                    "reviewState": "AutoApproved",
                    "matchType": "PositiveExactMatch",
                    "bid": 1.0,
                    "inputKeywords": {
                        "positiveExact": [
                            "bar sound",
                            "sound bar",
                            "sound-bar",
                            "sound bars",
                            "sounds bar"
                        ]
                    },
                    "createdAt": "2025-01-01T07:00:00",
                    "updatedAt": "2025-01-01T08:00:00"
                },
                "dolby soundbar": {
                    "reviewState": "Recommended",
                    "matchType": "PositiveExactMatch",
                    "bid": null,
                    "inputKeywords": {
                        "positiveExact": [
                            "dolby soundbars",
                            "soundbar dolby"
                        ]
                    },
                    "createdAt": "2025-01-01T07:00:00",
                    "updatedAt": "2025-01-01T08:00:00"
                },
                "atmos": {
                    "matchType": "NegativeBroad",
                    "inputKeywords": {
                        "negativeBroad": [
                            "atmos"
                        ]
                    },
                    "createdAt": "2025-01-01T07:00:00",
                    "updatedAt": "2025-01-01T08:00:00"
                }
            },
            "recommended": [
                "atmos",
                "dolby soundbars",
                "sound bar",
                "sound bars",
                "soundbar dolby"
            ]
        }
    },
    /* omitted if no errors */
    "errors": [],
    /* omitted if no warnings */
    "warnings": []
}
```

***

## Add or remove Keyword from Line Item

<EndpointBadge method="post">
  ```http theme={null}
  https://api.criteo.com/{version}/retail-media/line-items/{lineItemId}/keywords/add-remove
  ```
</EndpointBadge>

<Info>
  **Negative Targeting v1**

  The negative keyword targeting in this API will eventually replace the [Negative Keyword Targeting](/retail-media/v2025.10/docs/negative-keywords-open-auction-only) endpoints. You may continue using those endpoints without disrupting your services. We recommend reviewing and testing the new Keyword endpoints to prepare for a future migration to these new endpoints.
</Info>

**Sample Request**

<CodeGroup>
  ```bash cURL theme={null}
  curl -L -X POST "https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/add-remove" \
      -H "Authorization: Bearer <MY_ACCESS_TOKEN>" \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      -d '{
              "data": {
                  "id": "358669652976373760",
                  "type": "RetailMediaKeywordAddRemove",
                  "attributes": {
                      "keywords": [
                          {
                              "phrase": "cookies and bread",
                              "matchType": "PositiveExactMatch",
                              "isDeleted": "false"
                          },
                          {
                              "phrase": "raspberry",
                              "matchType": "NegativeExactMatch",
                              "isDeleted": "false"
                          },
                          {
                              "phrase": "potatoes",
                              "matchType": "NegativeExactMatch",
                              "isDeleted": "true"
                          }
                      ]
                  }
              }
          }'
  ```

  ```python Python expandable theme={null}
  import http.client
  import json

  conn = http.client.HTTPSConnection("api.criteo.com")
  payload = json.dumps({
      "data": {
          "id": "358669652976373760",
          "type": "RetailMediaKeywordAddRemove",
          "attributes": {
              "keywords": [
                  {
                      "phrase": "cookies and bread",
                      "matchType": "PositiveExactMatch",
                      "isDeleted": "false"
                  },
                  {
                      "phrase": "raspberry",
                      "matchType": "NegativeExactMatch",
                      "isDeleted": "false"
                  },
                  {
                      "phrase": "potatoes",
                      "matchType": "NegativeExactMatch",
                      "isDeleted": "true"
                  }
              ]
          }
      }
  })

  headers = {
      'Authorization': 'Bearer <MY_ACCESS_TOKEN>',
      'Content-Type': 'application/json',
      'Accept': 'application/json'
  }

  conn.request("POST", "/{version}/retail-media/line-items/358669652976373760/keywords/add-remove", payload, headers)

  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))
  ```

  ```java Java expandable theme={null}

  OkHttpClient client = new OkHttpClient().newBuilder()
      .build();

  MediaType mediaType = MediaType.parse("application/json");

  RequestBody body = RequestBody.create(mediaType, """
  {
      "data": {
          "id": "358669652976373760",
          "type": "RetailMediaKeywordAddRemove",
          "attributes": {
              "keywords": [
                  {
                      "phrase": "cookies and bread",
                      "matchType": "PositiveExactMatch",
                      "isDeleted": "false"
                  },
                  {
                      "phrase": "raspberry",
                      "matchType": "NegativeExactMatch",
                      "isDeleted": "false"
                  },
                  {
                      "phrase": "potatoes",
                      "matchType": "NegativeExactMatch",
                      "isDeleted": "true"
                  }
              ]
          }
      }
  }
  """);

  Request request = new Request.Builder()
      .url("https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/add-remove")
      .method("POST", body)
      .addHeader("Authorization", "Bearer <MY_ACCESS_TOKEN>")
      .addHeader("Content-Type", "application/json")
      .addHeader("Accept", "application/json")
      .build();

  Response response = client.newCall(request).execute();

  ```

  ```php PHP expandable theme={null}
  <?php
  require_once 'HTTP/Request2.php';
  $request = new HTTP_Request2();
  $request->setUrl('https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/add-remove');
  $request->setMethod(HTTP_Request2::METHOD_POST);
  $request->setConfig(array(
      'follow_redirects' => TRUE
  ));
  $request->setHeader(array(
      'Authorization' => 'Bearer <MY_ACCESS_TOKEN>',
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
  ));

  $request->setBody(json_encode(array(
      "data" => array(
          "id" => "358669652976373760",
          "type" => "RetailMediaKeywordAddRemove",
          "attributes" => array(
              "keywords" => array(
                  array(
                      "phrase" => "cookies and bread",
                      "matchType" => "PositiveExactMatch",
                      "isDeleted" => "false"
                  ),
                  array(
                      "phrase" => "raspberry",
                      "matchType" => "NegativeExactMatch",
                      "isDeleted" => "false"
                  ),
                  array(
                      "phrase" => "potatoes",
                      "matchType" => "NegativeExactMatch",
                      "isDeleted" => "true"
                  )
              )
          )
      )
  ), JSON_PRETTY_PRINT));

  try {
      $response = $request->send();
      if ($response->getStatus() == 200) {
          echo $response->getBody();
      } else {
          echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase();
      }
  } catch(HTTP_Request2_Exception $e) {
      echo 'Error: ' . $e->getMessage();
  }

  ```
</CodeGroup>

**Sample Response**\
*200 successful status will return an empty object array*

```json theme={null}
{}
```

***

## Set bid on Keyword

💡**Info**: Bids can be set on a keyword at any time, even when the keyword are still `InReview` state

<EndpointBadge method="post">
  ```http theme={null}
  https://api.criteo.com/{version}/retail-media/line-items/{lineItemId}/keywords/set-bid
  ```
</EndpointBadge>

**Sample Request**

<CodeGroup>
  ```bash cURL theme={null}
  curl -L -X POST "https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/set-bid" \
      -H "Authorization: Bearer <MY_ACCESS_TOKEN>" \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      -d '{
              "data": {
                  "type": "RetailMediaKeywordsSetBid",
                  "id": "358669652976373760",
                  "attributes": {
                      "keywords": [
                          {"phrase": "eggs", "bid": "0.50"},
                          {"phrase": "milk", "bid": "0.50"}
                      ]
                  }
              }
          }'
  ```

  ```python Python theme={null}
  import http.client
  import json
  conn = http.client.HTTPSConnection("api.criteo.com")
  payload = json.dumps({
      "data": {
          "id": "358669652976373760",
          "type": "RetailMediaKeywordsSetBid",
          "attributes": {
              "keywords": [
                  {"phrase": "eggs", "bid": "0.50"},
                  {"phrase": "milk", "bid": "0.50"}
              ]
          }
      }
  })

  headers = {
      'Content-Type': 'application/json',
      'Accept': 'text/plain',
      'Authorization': 'Bearer <MY_ACCESS_TOKEN>'
  }
  conn.request("POST", "/{version}/retail-media/line-items/358669652976373760/keywords/set-bid", payload, headers)

  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))
  ```

  ```java Java theme={null}
  OkHttpClient client = new OkHttpClient().newBuilder()
      .build();

  MediaType mediaType = MediaType.parse("application/json");

  RequestBody body = RequestBody.create(mediaType, """
  {
      "data": {
          "id": "358669652976373760",
          "type": "RetailMediaKeywordsSetBid",
          "attributes": {
              "keywords": [
                  {"phrase": "eggs", "bid": "0.50"},
                  {"phrase": "milk", "bid": "0.50"}
              ]
          }
      }
  }
  """);

  Request request = new Request.Builder()
      .url("https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/set-bid")
      .method("POST", body)
      .addHeader("Content-Type", "application/json")
      .addHeader("Accept", "application/json")
      .addHeader("Authorization", "Bearer <MY_ACCESS_TOKEN>")
      .build();

  Response response = client.newCall(request).execute();
  ``
  ```

  ```php PHP expandable theme={null}
  <?php
  require_once 'HTTP/Request2.php';
  $request = new HTTP_Request2();
  $request->setUrl('https://api.criteo.com/{version}/retail-media/line-items/358669652976373760/keywords/set-bid');
  $request->setMethod(HTTP_Request2::METHOD_POST);
  $request->setConfig(array(
      'follow_redirects' => TRUE
  ));
  $request->setHeader(array(
      'Content-Type' => 'application/json',
      'Accept' => 'text/plain',
      'Authorization' => 'Bearer <MY_ACCESS_TOKEN>'
  ));

  $request->setBody(json_encode(array(
      "data" => array(
          "id" => "358669652976373760",
          "type" => "RetailMediaKeywordsSetBid",
          "attributes" => array(
              "keywords" => array(
                  array("phrase" => "eggs", "bid" => "0.50"),
                  array("phrase" => "milk", "bid" => "0.50")
              )
          )
      )
  ), JSON_PRETTY_PRINT));

  try {
      $response = $request->send();
      if ($response->getStatus() == 200) {
          echo $response->getBody();
      } else {
          echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase();
      }
  } catch(HTTP_Request2_Exception $e) {
      echo 'Error: ' . $e->getMessage();
  }
  ```
</CodeGroup>

**Sample Response**\
*200 successful status will return an empty object array*

```json theme={null}
{}
```

***

## Responses

<table>
  <thead>
    <tr>
      <th>
        <p>
          Response
        </p>
      </th>

      <th>
        <p>
          Description
        </p>
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <p>
          🔵

          <code>
            200
          </code>

          OK
        </p>
      </td>

      <td>
        <p>
          Call completed with success
        </p>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          🔵

          <code>
            201
          </code>

          OK
        </p>
      </td>

      <td>
        <ul>
          <li>
            The call to add/remove the keyword from the line item was executed successfully
          </li>

          <li>
            The call to set keyword bid to the line item was executed successfully
          </li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>
        <p>
          🔴

          <code>
            400
          </code>

          * Bad Request
        </p>
      </td>

      <td>
        <p>
          Setting a bid for a positive keyword that doesn't exist on the line item.
        </p>

        <p>
          <b>
            Error Message
          </b>
        </p>

        <p>
          <code>
            "On line item \{lineItemId} normalized keyword "\{keyword}"/en\_US not found"
          </code>
        </p>

        <p>
          Setting a keyword bid above the line-item

          <code>
            maxBid
          </code>

          value will result in a 400 bad request error message. In this example, the

          <code>
            maxBid
          </code>

          value is at least 0.40.
        </p>

        <p>
          <b>
            Error Message
          </b>
        </p>

        <p>
          <code>
            "Invalid bid value, bid greater than maximum of 1.00000000, found for keyword: "
          </code>
        </p>

        <p>
          Setting a keyword bid below the retailer

          <code>
            minBid
          </code>

          value will result in a 400 bad request error message. In this example, the

          <code>
            minBid
          </code>

          value is at least 0.40.
        </p>

        <p>
          <b>
            Error Message
          </b>
        </p>

        <p>
          <code>
            "Invalid bid value, bid less than minimum of 0.4000, found for keyword: "
          </code>
        </p>
      </td>
    </tr>
  </tbody>
</table>
