IntegrationError Handling

Error Handling

This page covers the response status codes the Create Session endpoint can return, the recommended retry strategy, and a debug checklist when the endpoint responds with 401 Invalid Signature or 422 Validation Failed.

Status Codes

CodeMeaningRetry?
200Success - session created-
401Unauthorized - signature is invalidNo
403Forbidden - domain not whitelisted for tokenized widget accessNo
404Not Found - partner not found or inactiveNo
422Validation Failed - payload invalidNo
429Too Many Requests - rate limit exceededYes
500Internal Server ErrorYes
502Bad GatewayYes
503Service UnavailableYes
504Gateway TimeoutYes
⚠️

Do not retry on 401, 404, or 422. These are caused by bad requests on the partner side - retries will keep failing and may cause unnecessary load. Investigate the request payload first.

Retry Strategy

When a retryable status code is returned, use exponential backoff with jitter to avoid thundering-herd retries.

  • Max 3 attempts, base delay 500 ms.
  • Formula: min(500 * 2^attempt + random(0..300), 8000) ms.
  • Approximate intervals: ~500 ms, ~1000 ms, ~2000 ms.
  • For endpoints with side-effect duplication risk, send an idempotency key or unique request key alongside the retry.

If the final retry attempt still fails, stop, log the final error, and forward the failure to your internal monitoring or alerting system.

To prevent continuously calling the API when failure rate is high, apply a circuit breaker:

ParameterRecommended value
Rolling window20 requests
Minimum sample10 requests
Failure rate threshold50%
Slow call threshold> 3 seconds
Slow call rate threshold60%
Open state duration30 seconds
Half-open trial3 requests
  • OPEN: fail-fast new requests for the open state duration.
  • HALF_OPEN: only allow a few trial requests through.
  • CLOSED: restored after 3 consecutive half-open successes.

Authentication Debug Guide

When you receive 401 Invalid Signature, walk through this checklist:

  • Does the partnerId in the URL exactly match the partnerId used in the canonical string?
  • Field order: partnerId | user_id | email | name | company_id | candidate_ids_csv?
  • Field delimiter is |, candidate_id delimiter is ,?
  • Empty optional fields are preserved as empty strings (not omitted)?
  • No stray spaces, newlines, or hidden characters in the canonical string before hashing?
  • secretKey matches the current environment (dev secretKey ≠ prod secretKey)?
  • candidate_id order in the canonical string matches the array order in the payload?

When you receive 422 Validation Failed:

  • Required fields present: user.user_id, user.email, user.name, signature?
  • Valid email format?
  • Correct user.company and user.candidates structure?
[DEBUG] partnerId: psikologihub-1024
[DEBUG] canonical: psikologihub-1024|USR-001|[email protected]|John Doe|COMP-001|CND-001,CND-002
[DEBUG] generated_signature: <hex>
[DEBUG] request_signature:   <hex>
[DEBUG] match_signature:     true/false
🚫

Never log the secretKey, full session tokens, or raw signatures. If logs are stored in a shared environment, mask or redact any sensitive content.