Skip to main content

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.

Not yet available to API tokens

This endpoint currently requires session authentication; Personal Access Token scope support is in progress.

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 by oauth/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 to config('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​

Created

Response Headers
    Content-Type