API
Value List

Value List

Provides a way to resolve valueListId found in Universal Tracker models.

/v1/value-list

Model interface schema in TypeScript:

interface ValueList {
  // Unique Id
  _id: string;
 
  options: {
    // Static code used to represent value list option
    code: string;
 
    // Please note that "name" property can change at any point and should not be relied on.
    name: string;
  }[];
}

Retrieve Value List

GET /v1/value-list/:id

Retrieve specific value list by id

Request

curl --location 'https://api.sg.g17.eco/v1/value-list/5da7088e979d0d176d8b3f6a' \
--header 'Authorization: Bearer TOKEN_HERE'

Response

{
    "success": true,
    "data": {
        "_id": "5da7088e979d0d176d8b3f6a",
        "options": [
            {
                "code": "yes",
                "name": "Yes"
            },
            {
                "code": "no",
                "name": "No"
            }
        ]
    }
}
 

Lookup multiple Value Lists

POST /v1/value-list/lookup

Retrieve multiple value lists by their IDs in a single request. Maximum 100 IDs allowed per request.

Request Body

{
  "ids": [
    "5da7088e979d0d176d8b3f6a",
    "5da7088e979d0d176d8b3f6b"
  ]
}

Example Request

curl --location 'https://api.sg.g17.eco/v1/value-list/lookup' \
--header 'Authorization: Bearer TOKEN_HERE' \
--header 'Content-Type: application/json' \
--data '{
  "ids": [
    "5da7088e979d0d176d8b3f6a",
    "5da7088e979d0d176d8b3f6b"
  ]
}'

Response

{
  "success": true,
  "data": [
    {
      "_id": "5da7088e979d0d176d8b3f6a",
      "options": [
        { "code": "yes", "name": "Yes" },
        { "code": "no", "name": "No" }
      ]
    },
    {
      "_id": "5da7088e979d0d176d8b3f6b",
      "options": [
        { "code": "option1", "name": "Option 1" },
        { "code": "option2", "name": "Option 2" }
      ]
    }
  ]
}

Error Response (Invalid Request)

{
  "success": false,
  "message": "Invalid request body",
  "errors": [
    {
      "code": "invalid_type",
      "expected": "string",
      "received": "number",
      "path": [
        "ids",
        0
      ],
      "message": "Expected string, received number"
    }
  ]
}