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

# Tenant ID

> How to handle customer-specific data in Logic.

## Tenant ID

The Logic API supports [multitenancy](https://en.wikipedia.org/wiki/Multitenancy), allowing you to separate data and behavior for each of your customers.

By including a `tenantId` in your request, you tell Logic which customer the execution belongs to. Logic will keep data, learning, and behavior isolated for each `tenantId`, ensuring that one customer's data is never used to influence another's.

Even if you're not using dynamic learning yet, you can include a `tenantId` in your executions. That way, if you enable dynamic learning later, it will automatically stay isolated per tenant.

<Info>
  Learn more about the Logic's dynamic learning in the [Dynamic
  Learning](/api-reference/execution-params/dynamic-learning) section.
</Info>

## Isolating Dynamic Learning with `tenantId`

When using dynamic learning, you can isolate the learning process by specifying a `tenantId` parameter. This allows you to test and evaluate the impact of dynamic learning on different sets of executions without affecting the overall learning process.

This is especially useful when serving multiple tenants, as it ensures each one's learning data remains isolated.

### Example with `useDynamicLearning` & `tenantId`

Below are example requests using both `useDynamicLearning=true` and `tenantId` to isolate learning for a specific customer.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST 'https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}'
      -H "Authorization: Bearer $LOGIC_API_TOKEN"
      -H "Content-Type: application/json"
      -d '{
        /* your input JSON here */
      }'
  ```

  ```bash httpie theme={null}
  http -A bearer -a $LOGIC_API_TOKEN POST 'https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}'
      --raw '{
        {YOUR INPUT JSON HERE}
      }'
  ```

  ```python python theme={null}
  import requests

  LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  headers = {
      "Authorization": f"Bearer {LOGIC_API_TOKEN}",
      "Content-Type": "application/json"
  }

  response = requests.post(
      "https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}",
      headers=headers,
      json={
          # Add your agent input here
      }
  )

  print(response.json())
  ```

  ```ruby ruby theme={null}
  require 'net/http'
  require 'json'

  uri = URI('https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == 'https'

  LOGIC_API_TOKEN = 'ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = "Bearer #{LOGIC_API_TOKEN}"
  request['Content-Type'] = 'application/json'
  request.body = '
      {
        {YOUR INPUT JSON HERE}
      }
  '

  response = http.request(request)
  puts response.body
  ```

  ```javascript javascript theme={null}
  const LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

  const response = await fetch(
    "https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${LOGIC_API_TOKEN}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        // Add your agent input here
      }),
    },
  );

  const data = await response.json();
  console.log(data);
  ```

  ```go go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
      "io/ioutil"
  )

  const (
      LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  )

  func main() {
      jsonStr := `{
        {YOUR INPUT JSON HERE}
      }`

      // Create request
      req, err := http.NewRequest("POST", "https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}", bytes.NewBufferString(jsonStr))
      if err != nil {
          panic(err)
      }

      // Add headers
      req.Header.Set("Content-Type", "application/json")
      req.Header.Set("Authorization", "Bearer " + LOGIC_API_TOKEN)

      // Send request
      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      // Read response
      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          panic(err)
      }

      fmt.Println(string(body))
  }
  ```

  ```java java theme={null}
  // Java requires the OkHttp library. You can add it to your project using Maven or Gradle. Learn more in the Java Quick Start section of the API reference.


  import okhttp3.*;
  import java.io.IOException;

  public class ApiClient {
      private static final String LOGIC_API_TOKEN = "ls-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

      public static void main(String[] args) {
          OkHttpClient client = new OkHttpClient();


          MediaType JSON = MediaType.get("application/json; charset=utf-8");
          String jsonBody = """
      {
        {YOUR INPUT JSON HERE}
      }
          """;

          RequestBody body = RequestBody.create(jsonBody, JSON);
          Request request = new Request.Builder()
              .url("https://api.logic.inc/v1/agents/{agent_id}/executions?useDynamicLearning=true&tenantId={tenant_id}")
              .post(body)
              .addHeader("Authorization", "Bearer " + LOGIC_API_TOKEN)

              .addHeader("Content-Type", "application/json")
              .build();

          try (Response response = client.newCall(request).execute()) {
              String responseBody = response.body().string();
              System.out.println(responseBody);
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  ```
</CodeGroup>

<replaceID />
