"BOTH"One of: BUYERSELLERBOTHPer-endpoint reference for the OFFER-HUB Users API - create a user with an automatic balance and link a user's Airtm account - with real DTO fields, enums, response shapes, error codes, idempotency behavior, and cURL plus TypeScript SDK examples.
A user is a buyer, a seller, or both on your marketplace. Creating one also creates their balance record, and a wallet when the payment provider needs one. Two routes live in UsersController (apps/api/src/modules/users/users.controller.ts) and delegate to UsersService (apps/api/src/modules/users/users.service.ts). With the global /api/v1 prefix from apps/api/src/main.ts, the paths below are the full routes.
Balance routes such as GET /users/{userId}/balance are covered in the API Reference overview and Balance SDK reference.
UsersController is decorated with @UseGuards(ApiKeyGuard, ScopeGuard) and both handlers declare @Scopes('write'). A key without the write scope gets 403 INSUFFICIENT_SCOPE. Send Authorization: Bearer <api key or short-lived token>; see Auth Endpoints.
Both request bodies bind a DTO (apps/api/src/modules/users/dto/create-user.dto.ts, link-airtm.dto.ts). The global ValidationPipe runs with whitelist, forbidNonWhitelisted and transform enabled (apps/api/src/main.ts), so unknown properties are rejected with 400 VALIDATION_ERROR rather than ignored.
Both handlers return { data: ... }, which ResponseInterceptor leaves untouched because it is a single-key payload with data. The response is therefore { "data": { ... } } with no meta object. Errors use { "error": { "code", "message", "details?" } }; see Error Codes.
The global idempotency guard and interceptor apply to both POST routes, so an optional Idempotency-Key header (UUID v4, scoped to your key, replayed for 24 hours by default) is honored on both. POST /users is also naturally idempotent on externalUserId (see below). The global rate limit is 100 requests per 60 seconds per key.
Creates a user and their balance in one transaction. If a user with the same externalUserId already exists, the existing user is returned instead of an error.
What the service does, in order (UsersService.createUser):
externalUserId; if found, returns that user without changes.usr_ prefix and, in one database transaction, creates the user with status ACTIVE and a balance of 0.00 available and 0.00 reserved in USD.USER_CREATED event.The controller comment says an existing user returns 200 OK, but the handler declares no @HttpCode, so NestJS applies its default and both cases return 201 Created. To tell them apart, compare createdAt or check for your own record first.
Verifies a user's email against Airtm and stores the link. If the user is already linked, the stored link is returned and Airtm is not called again.
On a first successful link the service also emits a USER_AIRTM_LINKED event. The already-linked shortcut returns success without re-verifying the email, so the email in that response is whatever you just sent.
USER_NOT_FOUND appears twice with different meanings. With HTTP 404 it means your usr_ ID does not exist. With HTTP 400 it means Airtm has no account for the email. Branch on the status together with the code.
users.create and users.linkAirtm methods