Log out
Logs a user out of the app of a business, ending the current user session. The access token of the user is invalidated after logging out, and the user must log in again to access the app of the business.
Note:
Calling the API invalidates the user's access token across all active sessions. If a user is signed in on multiple devices, logging out from one device may invalidate the shared access token for all active sessions. Subsequent API requests made with the invalidated token will return an HTTP 401 Unauthorized response.
To handle this scenario, mobile apps should:
- Clear the locally stored access token and session data.
- End the current local session.
- Redirect the user to the login screen.
- Display a session-ended (logged out) message, if applicable.
This behavior is particularly relevant for applications that use legacy authentication, where multiple active sessions may share the same access token.
Headers
- Type: stringx
-pch -digest requiredThe signature for the API call
- Type: stringContent
- Type requiredSet this header to application/json.
- Type: stringAcceptrequired
Advertises which content types the client is able to understand
- Type: stringAccept
- Language Preferred language
- Type: stringpunchh
-app -device -id requiredThe app device ID helps Punchh identify each device so that certain rewards can be awarded individually to each device instead of per user. For example, the sign-up reward is given to each device ID to prevent fraudulent sign-ups so that a user cannot do repeated sign-ups from a single device to get rewards. It should not change even if the user resets a device. See the sample code to generate the punchh-app-device-id header.
- Type: stringUser
- Agent requiredUsed to identify the software, device, and application initiating the request, providing information about the client to the server. For details, see User Agent.
- Type: stringAuthorizationrequired
Used to authorize the request with access_token. It should be supplied as
Bearer ACCESS_TOKEN_GOES_HERE.
Body
- Type: stringclientrequired
OAuth client ID provided by the business
- Type: stringaccess
_token Token issued to the user after logging into the app of the business
- Type: stringgcm
_token Google Cloud Messaging (GCM) or Firebase Cloud Messaging (FCM) token that allows push notifications to be received on the registered device of the user
Responses
- application/json
- application/json
- application/json
- application/json
- application/json
curl https://SERVER_NAME_GOES_HERE.punchh.com/api2/mobile/users/logout \
--request DELETE \
--header 'x-pch-digest: {{$$.env.signature}}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Accept-Language: en' \
--header 'punchh-app-device-id: APP_DEVICE_ID_GOES_HERE' \
--header 'User-Agent: AppName/AppVersion/BuildNumber (OS; Model; MANUFACTURER; MODEL; OS Version)' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--data '{
"client": "CLIENT_GOES_HERE",
"access_token": "ACCESS_TOKEN_GOES_HERE"
}'
{}