Skip to main content
POST
/
v1
/
settings
/
metadata-indexes
/
entities
/
{entity_name}
Create a Metadata Index
curl --request POST \
  --url https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name} \
  --header 'Content-Type: application/json' \
  --data '
{
  "metadataKey": "tier",
  "unique": false,
  "sparse": true
}
'
import requests

url = "https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name}"

payload = {
"metadataKey": "tier",
"unique": False,
"sparse": True
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({metadataKey: 'tier', unique: false, sparse: true})
};

fetch('https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'metadataKey' => 'tier',
'unique' => false,
'sparse' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name}"

payload := strings.NewReader("{\n \"metadataKey\": \"tier\",\n \"unique\": false,\n \"sparse\": true\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name}")
.header("Content-Type", "application/json")
.body("{\n \"metadataKey\": \"tier\",\n \"unique\": false,\n \"sparse\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://ledger.sandbox.lerian.net/v1/settings/metadata-indexes/entities/{entity_name}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadataKey\": \"tier\",\n \"unique\": false,\n \"sparse\": true\n}"

response = http.request(request)
puts response.read_body
{
  "indexName": "metadata.tier_1",
  "entityName": "transaction",
  "metadataKey": "tier",
  "unique": false,
  "sparse": true
}

Headers

Content-Type
string

The type of media of the resource. Recommended value is application/json.

X-Request-Id
string<uuid>

A unique identifier used to trace and track each request.

Authorization
string

Bearer JWT token for authentication. Required when PLUGIN_AUTH_ENABLED=true (enforced in multi-tenant deployments). Optional in default OSS single-tenant mode. Format: Bearer <token>

Path Parameters

entity_name
enum<string>
required

The name of the entity for which the metadata index will be created or managed.

Available options:
organization,
ledger,
asset,
segment,
portfolio,
account,
transaction,
operation,
account_type,
operation_route,
transaction_route

Body

application/json

The request body to create a metadata index.

metadataKey
string
required

The metadata key to be indexed. This key must match the metadata field name used in your entities.

Maximum string length: 100
Pattern: ^[a-zA-Z][a-zA-Z0-9_]*$
Example:

"tier"

unique
boolean
default:false

Indicates whether the index enforces uniqueness. When set to true, duplicate values for this metadata key will not be allowed.

Example:

false

sparse
boolean
default:true

Indicates whether the index is sparse. When set to true, only documents containing the indexed field will be included in the index.

Example:

true

Response

Indicates that the metadata index was successfully created and the operation was completed as expected.

The response body for a metadata index.

indexName
string
required

The name of the index in the database.

Example:

"metadata.tier_1"

entityName
string
required

The name of the entity associated with the index.

Example:

"transaction"

metadataKey
string
required

The metadata key used in the index.

Example:

"tier"

unique
boolean
required

Indicates whether the index enforces uniqueness.

Example:

false

sparse
boolean
required

Indicates whether the index is sparse (ignores documents without the indexed field).

Example:

true