Complete OAuth
POST/api/temu/oauth/complete
Exchanges the OAuth authorization code returned by Temu for an access token and creates a new TemuIntegrationInstance persisted with that token.
Any valid API token can call this endpoint — no specific scope required. Manage tokens.
The frontend calls this after Temu redirects the merchant back to /v2/integrations/temu/callback carrying state, code, and callback_host. The callback URL on the central landlord is /api/temu/oauth/callback (not documented here — it's a browser-redirected endpoint, not a JSON API).
After the instance is created, initial sync jobs (warehouses, carriers, categories, products, orders) are dispatched.
Request body (raw JSON, not a FormRequest):
state(string, required) — The state returned byoauth/initialize. Used to look up the stored name + environment + integration_settings from the file cache.code(string, required) — Authorization code returned by Temu in the redirect query string.callback_host(string, optional) — API host Temu returned on the redirect (e.g.openapi-b-us.temu.com). Used as the API base URL for the new instance; falls back toconfig('temu.<env>.api_url')when not present.
Response: A 201 Created with the newly-persisted TemuIntegrationInstance resource. The shape is the same as GET /api/temu/{integrationInstance} (the Temu integration instance object which extends sales channel integration list view object).
Authentication: Bearer token (Sanctum).
Throws: Exception when state or code is missing, when the OAuth session has expired, has already been completed, or when the token exchange with Temu fails.
Request
Responses
- 201
- 401
- 403
- 422
- 429
- 500
Created
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Validation failed — the body is a field → messages map (Laravel shape) or the platform envelope with a stable machine-readable code. Fix the payload and resubmit.
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.
Internal Server Error