Get Temporary Access Token

Temporary Token is a token that can be used to invoke Verify with GoPay without user auth.

Description

  • This API allows Midtrans partners to exchange a user's GoPay payment linking token for a temporary token.
  • The temporary token then can be used to initiate "Verify with Gopay" flow on behalf of the user, without asking the user to re-do the authentication process (Input Phone Number, OTP challenge, and Pin challenge).
  • This is a backend-to-backend API. The caller must have a valid x-merchant-id, and must supply the user's GoPay payment linking token obtained from GoPay.

Request

Attribute

Value

Method

GET

Hostname

Staging: https://identity.staging.midtrans.com
Production: https://identity.midtrans.com

Path

/forward/gopay-id/identity/v1/gopay-id/token

Request Headers

KeyTypeRequired?Description
x-merchant-idstringYESMerchant identifier issued by Gopay.
authorizationstringYESThe user's Gopay payment linking token. Do not prefix with Bearer.
request-idstringYESA unique ID for this request, used for distributed tracing. Recommended: UUID v4.

Example

curl --location 'https://identity.midtrans.com/forward/gopay-id/identity/v1/gopay-id/token' \
  --header 'x-merchant-id: 5a6a693d-a13a-41c5-8f78-a0b02144220d' \
  --header 'correlation-id: f47ac10b-58cc-4372-a567-0e02b2c3d479' \
  --header 'authorization: MjAyMDA5MDFmOGQ0NWVhMi1iYzBjLTQ3ZTUtYjU1NC0wMDVjMzYyYzE3N2U6NGVlNzAyZmMtYWY2Ny00NjJjLWJmYTktZWQwMTBmZWQ4OTli'

Response

HTTP Status Codes

HTTP StatusScenario
200 OKToken exchange successful.
400 Bad RequestMissing or invalid request headers, or merchant not configured.
500 Internal Server ErrorUpstream service failure during token generation or account resolution.
503 Service UnavailableA dependency is temporarily unreachable.

Success Response

Response Body:

{
  "success": true,
  "data": {
    "token": "<base64_encoded_jwt_token>"
  }
}
FieldTypeDescription
successbooleantrue on success.
data.tokenstringBase64-encoded token. Pass this to the Gopay Enterprise SDK.

Error Responses

All error responses share the following structure:

{
  "success": false,
  "errors": [
    {
      "code": "<error_code>",
      "entity": "<field_or_entity>",
      "cause": "<description>"
    }
  ]
}
FieldTypeDescription
successbooleanfalse on error.
errors[].codestringMachine-readable error code.
errors[].entitystringThe field or resource related to the error.
errors[].causestringHuman-readable description of what went wrong.

Bad Request

ScenarioCodeEntityCause
x-merchant-id header is missing1539IdentityExternalAdapterMissing required header
authorization header is missing1539authorizationAuthorization header is required for this endpoint
correlation-id header is missing1539correlation-idMissing required header
Merchant is not registered or configured1539x-merchant-idMerchant is not configured in the system
authorization token has an invalid format1539authorizationFailed to decode authorization token

Example:

{
  "success": false,
  "errors": [
    {
      "code": "404",
      "entity": "gopayAccountId",
      "cause": "GoPay user not found"
    }
  ]
}

Internal Server Error

ScenarioCodeEntityCause
Failed to generate temporary token900identityTokenFailed to generate temporary token
Failed to introspect merchant authorization900authorizationInternal service error during authorization introspection
Failed to resolve GoPay account ID900gopayAccountIdInternal service error during account resolutio

Example:

{
  "success": false,
  "errors": [
    {
      "code": "900",
      "entity": "identityToken",
      "cause": "Failed to generate identity token"
    }
  ]
}

Service Unavailable

A downstream dependency is temporarily unreachable. Retry with exponential backoff.

Example:

{
  "success": false,
  "errors": [
    {
      "code": "900",
      "entity": "upstreamService",
      "cause": "Service temporarily unavailable"
    }
  ]
}