Skip to content

List Tenant IDs

List all the tenant ID values (values in the tenant_id field) used in your documents.

Endpoint

POST /v20241104/list-tenant-ids

API Request

  • Required Parameters

    No required parameters. Please note: API request must include a JSON body, even if empty {}.


    Optional Parameters


    limit integer

    Limit on the maximum number of results to return per request. Default is 10.

    Additional results can be fetched if more are available.

    Min: 1   Max: 100


    after string

    A cursor used for pagination when there are more results.

    Info

    • Don't include this parameter in the initial API request.
    • Set this to the next_after value from the previous API response to fetch the subsequent set of results.

    MinLength: 1   MaxLength: 250

  • POST /v20241104/list-tenant-ids


    curl -X POST "https://api.gainly.ai/v20241104/list-tenant-ids" \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY_HERE" \  # (1)!
      -d '{
        "limit": 5
      }'
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    # Prompt for AI coding assistants/IDEs (e.g., ChatGPT, Claude, GitHub Copilot, Cursor, Windsurf)
    
    Using the Gainly API:
    1. Write code to call the list_tenant_ids operation (see OpenAPI spec: https://api.gainly.ai/v20241104/openapi.json)
    2. Implement authentication using the header "X-API-Key" as described in the docs: https://docs.gainly.ai/latest/api-reference/authentication/
    3. Implement rate limit handling as described in the docs: https://docs.gainly.ai/latest/api-reference/rate-limits/
    4. Implement error handling
    5. Handle the response according to the ListTenantIdsResults schema in the OpenAPI spec
    
    using System.Net.Http;
    using System.Text.Json;
    using System.Text;
    
    var client = new HttpClient();
    
    var url = "https://api.gainly.ai/v20241104/list-tenant-ids";
    
    var payload = new {
        limit = 5
    };
    
    var content = new StringContent(
        JsonSerializer.Serialize(payload),
        Encoding.UTF8,
        "application/json"
    );
    
    client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY_HERE"); // (1)!
    
    var response = await client.PostAsync(url, content);
    var result = await response.Content.ReadAsStringAsync();
    Console.WriteLine(result);
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    package main
    
    import (
        "bytes"
        "encoding/json"
        "fmt"
        "net/http"
    )
    
    func main() {
        url := "https://api.gainly.ai/v20241104/list-tenant-ids"
    
        payload := map[string]interface{}{
            "limit": 5,
        }
    
        jsonData, _ := json.Marshal(payload)
    
        req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
        req.Header.Set("Content-Type", "application/json")
        req.Header.Set("X-API-Key", "YOUR_API_KEY_HERE") // (1)!
    
        resp, _ := http.DefaultClient.Do(req)
        defer resp.Body.Close()
    
        var result map[string]interface{}
        json.NewDecoder(resp.Body).Decode(&result)
        fmt.Println(result)
    }
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    import java.net.http.HttpClient;
    import java.net.http.HttpRequest;
    import java.net.http.HttpResponse;
    import java.net.URI;
    
    var client = HttpClient.newHttpClient();
    
    var url = "https://api.gainly.ai/v20241104/list-tenant-ids";
    
    var payload = """
        {
            "limit": 5
        }
        """;
    
    var request = HttpRequest.newBuilder()
        .uri(URI.create(url))
        .header("Content-Type", "application/json")
        .header("X-API-Key", "YOUR_API_KEY_HERE") // (1)!
        .POST(HttpRequest.BodyPublishers.ofString(payload))
        .build();
    
    var response = client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    const axios = require('axios');  // or: import axios from 'axios';
    
    const url = 'https://api.gainly.ai/v20241104/list-tenant-ids';
    
    const payload = {
        limit: 5
    };
    
    const headers = {
        'Content-Type': 'application/json',
        'X-API-Key': 'YOUR_API_KEY_HERE' // (1)!
    };
    
    axios.post(url, payload, { headers })
        .then(response => console.log(response.data))
        .catch(error => console.error('Error:', error.message));
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    <?php
    
    $client = new \GuzzleHttp\Client();
    
    $url = 'https://api.gainly.ai/v20241104/list-tenant-ids';
    
    $payload = [
        'limit' => 5
    ];
    
    $response = $client->request('POST', $url, [
        'json' => $payload,
        'headers' => [
            'Content-Type' => 'application/json',
            'X-API-Key' => 'YOUR_API_KEY_HERE' # (1)!
        ],
    ]);
    
    echo $response->getBody();
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    import requests
    
    url = "https://api.gainly.ai/v20241104/list-tenant-ids"
    
    payload = {
        "limit": 5
    }
    
    headers = {
        "Content-Type": "application/json",
        "X-API-Key": "YOUR_API_KEY_HERE" # (1)!
    }
    
    response = requests.post(url, json=payload, headers=headers)
    data = response.json()
    print(data)
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.
    require 'json'
    require 'uri'
    require 'net/http'
    require 'openssl'
    
    url = URI('https://api.gainly.ai/v20241104/list-tenant-ids')
    
    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
    
    request = Net::HTTP::Post.new(url)
    request['Content-Type'] = 'application/json'
    request['X-API-Key'] = 'YOUR_API_KEY_HERE' # (1)!
    request.body = {
        limit: 5
    }.to_json
    
    response = http.request(request)
    puts response.read_body
    
    1. Replace YOUR_API_KEY_HERE with the value of your API key.

API Response

{
    "object": "list_tenant_ids_result",
    "url": "/v20241104/list-tenant-ids",
    "data": [
        "tenant223",
        "tenant123",
        "tenant345",
        "tenant456",
        "tenant567"
    ],
    "has_more": true,
    "next_after": "tenant567",
    "limit": 5,
    "after": null,
    "total_number_of_results": 7,
    "livemode": false
}

Pagination

Info

Pagination works differently for this endpoint compared to endpoints that return a list of documents.

The API response will include the following properties:

  • has_more boolean
    • Indicates whether more results are available.
    • If true, additional results can be retrieved.
    • If false, all results have been retrieved.
  • next_after string
    • Contains a string value if has_more is true, and NULL if has_more is false.
    • If has_more is true, pass this value as the after parameter in your next API request to fetch the subsequent set of results.

In addition, the following API response properties are present for informational purposes:

  • total_number_of_results integer
    • The total number of results.
  • after string
    • The current value of the after cursor.
  • limit integer
    • The number of results retrieved per request.

How to implement pagination for this endpoint

To implement pagination for this endpoint:

  • Don't include the after parameter in the initial API request.
  • If the has_more property in the API response is true, use the next_after value from the response as the after parameter in the next request. This will retrieve the next set of results.
    • Repeat this step until the has_more property in the API response is false.