Skip to main content
This page shows how to turn one-off request snippets into a reusable client layer that your application can share across routes, workers, and sync jobs. Use this approach when:
  • More than one service needs Uppzy access
  • You want one place for auth, timeout, retry, and error handling
  • You want testable helper methods instead of ad hoc fetch or requests calls

Design goals

Your internal client should centralize:
  • Base URL and API key handling
  • Default headers
  • Timeout settings
  • Retry and error classification
  • JSON parsing
  • Common endpoint methods
Keep business logic outside the client. The client should know how to call Uppzy, not when your product should escalate, retry a workflow, or create a support ticket.

Suggested module layout

Use one small owned module rather than copying helper functions into unrelated services.

TypeScript types

Keep only the response fields your application actually uses.

TypeScript client class

This example assumes you already use the error helper pattern from Error Handling Catalog.

Factory pattern

Keep environment wiring separate from business code.
This keeps API keys in runtime configuration and out of route files, queue definitions, and application templates.

Example usage in an API route

Python client class

For Python services, use a small class around requests.Session.

Testing with a fake transport

Keep your client testable without live network calls. One approach in JavaScript is to inject a transport function.
This lets you test:
  • Correct path construction
  • Header injection
  • Error mapping
  • Retry decisions
  • Timeout behavior
without depending on a live endpoint in every unit test.

Boundaries to keep

Put these inside the client layer:
  • HTTP construction
  • Authentication headers
  • Timeout and retry logic
  • Response parsing
  • Shared endpoint helpers
Keep these outside the client layer:
  • UI messaging
  • CRM handoff rules
  • Queue orchestration
  • Content approval decisions
  • Customer-specific business authorization

Production checklist

  • One owned Uppzy client module per codebase
  • API key and site ID loaded from runtime configuration
  • Shared error type used by routes and workers
  • Timeout and retry defaults defined once
  • Tests cover success, 401, 403, 429, 5xx, and timeout paths
  • Business logic lives above the client layer