Look Up a Session
You created a session and need to know how it ended, or whether a payment came out of it. To look up a payment on its own, see Look Up a Payment.
Integration Detailsβ
- API Endpoint:
GET /v2/sessions/{sessionId} - API Spec: Get Session
- Scope:
merchant - Path parameter:
sessionIdβ thesessionIdreturned when you created the session - Headers:
Authorization,X-Merchant-Id, andX-Upstream-Envin non-production. See API Headers.
The url field in the create-session response is this same endpoint, so you can poll it directly.
Requestβ
curl -X GET "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v2/sessions/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: <merchant-id>" \
-H "X-Upstream-Env: dev"
Read the resultβ
The HTTP status tells you whether the session is still open:
status | HTTP | What to do |
|---|---|---|
INITIATED | 202 | The customer has not finished. Keep polling. |
PENDING | 202 | The session is waiting to complete. Keep polling. |
COMPLETED | 200 | Done. Read the payment object if the session created a payment. |
FAILED | 200 | Done. The flow failed; create a new session to try again. |
CANCELED | 200 | Done. The session was canceled before completion. |
An expired session returns a SESSION_TIMEOUT error with HTTP 401, not a status value. Create a new session; expired sessions cannot be reused.
Sample Response β COMPLETED (200)
Key fields only. See the Get Session API Spec for the complete response.
{
"data": {
"status": "COMPLETED",
"payment": {
"id": "3222ac8a-c8fa-4426-bd99-e96a909569b0",
"merchantTransactionId": "30d279fa-9d7d-48c9-8e61-c3783eecf18c",
"status": "COMPLETED"
}
}
}
Read the payment from a sessionβ
When the session created a payment (for example PAYMENT_WITH_WALLET), the payment object has the same shape as the Payments API response, including paymentAllocations[] for single and split-tender payments. You do not need a second call to read the result.
- Take
payment.idif you later need to look up the payment, capture, cancel, or refund it. - A session can be
COMPLETEDwhile its payment is still settling. Check the paymentstatusbefore acting on it. - Field definitions and status meanings are in Payment β Status & Response Reference.
Errorsβ
| HTTP | Meaning | Action |
|---|---|---|
| 400 | Invalid sessionId | Check that it is the UUID from the create-session response |
| 401 | Invalid or expired token, or SESSION_TIMEOUT | Refresh the token, or create a new session |
| 403 | The merchant is not allowed to read this session | Check X-Merchant-Id and the merchant scope |
| 404 | Session not found | Check the ID and the environment |
| 422 | The request is valid but could not be processed | Check the sessionId value and the session state against the Get Session API Spec |
See Session Error Codes for the full list.