Skip to main content
GET
/
v2
/
consent
/
onboarding
/
{onboardingId}

Overview

Retrieves all consent sets associated with a specific onboardingId. Useful for recovering consent set information during registration flows.
This endpoint returns all consent sets created with the given onboardingId, including those that may have already been linked to users.

Endpoint

GET https://api.baanx.com/v2/consent/onboarding/{onboardingId}

Headers

HeaderRequiredDescription
x-client-keyYour public API key
x-us-envSet to true for US region routing

Path Parameters

ParameterTypeRequiredDescription
onboardingIdstringOnboarding identifier used during consent creation

Response

200 OK

{
  "onboardingId": "onboarding_abc123xyz",
  "consentSets": [
    {
      "consentSetId": "550e8400-e29b-41d4-a716-446655440001",
      "userId": "user_123abc456def",
      "onboardingId": "onboarding_abc123xyz",
      "tenantId": "tenant_baanx_prod",
      "policyType": "global",
      "completedAt": "2024-01-15T10:35:00Z",
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:35:00Z",
      "consents": [
        {
          "consentId": "consent_001",
          "consentType": "eSignAct",
          "consentStatus": "granted",
          "metadata": {
            "timestamp": "2024-01-15T10:30:00Z",
            "ipAddress": "192.168.1.1"
          },
          "createdAt": "2024-01-15T10:30:00Z",
          "updatedAt": "2024-01-15T10:30:00Z"
        }
      ]
    }
  ],
  "_links": {
    "self": {
      "href": "https://api.baanx.com/v2/consent/onboarding/onboarding_abc123xyz",
      "method": "GET"
    }
  }
}

404 Not Found

{
  "error": "Not found",
  "details": [
    "No consent sets found for onboardingId 'onboarding_abc123xyz'"
  ]
}

Code Examples

TypeScript

async function getConsentSetsByOnboardingId(onboardingId: string) {
  const response = await fetch(
    `https://api.baanx.com/v2/consent/onboarding/${onboardingId}`,
    {
      headers: {
        'x-client-key': process.env.BAANX_CLIENT_KEY!
      }
    }
  );

  if (!response.ok) {
    const error = await response.json();
    throw new Error(`Failed to retrieve consent sets: ${error.details.join(', ')}`);
  }

  return response.json();
}

const { consentSets } = await getConsentSetsByOnboardingId('onboarding_abc123xyz');
console.log(`Found ${consentSets.length} consent set(s)`);

Python

import requests

def get_consent_sets_by_onboarding_id(onboarding_id):
    response = requests.get(
        f'https://api.baanx.com/v2/consent/onboarding/{onboarding_id}',
        headers={
            'x-client-key': os.getenv('BAANX_CLIENT_KEY')
        }
    )

    response.raise_for_status()
    return response.json()

result = get_consent_sets_by_onboarding_id('onboarding_abc123xyz')
print(f"Found {len(result['consentSets'])} consent set(s)")

cURL

curl -X GET "https://api.baanx.com/v2/consent/onboarding/onboarding_abc123xyz" \
  -H "x-client-key: your_client_key"

Use Cases

Recover consent set ID from onboarding ID:
async function recoverConsentSetId(onboardingId: string): Promise<string | null> {
  try {
    const { consentSets } = await getConsentSetsByOnboardingId(onboardingId);

    if (consentSets.length === 0) {
      return null;
    }

    return consentSets[0].consentSetId;
  } catch (error) {
    console.error('Failed to recover consent set:', error);
    return null;
  }
}

const consentSetId = await recoverConsentSetId('onboarding_abc123xyz');
Check if onboarding ID has already been used:
async function hasExistingConsent(onboardingId: string): Promise<boolean> {
  try {
    const { consentSets } = await getConsentSetsByOnboardingId(onboardingId);
    return consentSets.length > 0;
  } catch (error) {
    if (error.status === 404) {
      return false;
    }
    throw error;
  }
}