Table of Contents
ToggleShort answer: AppsFlyer S2S 401 Unauthorized means the request was not authenticated. In AppsFlyer’s API reference, the 401 response is described as the key in the authentication header not being the S2S key for this app. The usual mistake is sending the wrong key, such as the Dev key, instead of the S2S key. Replace it with the S2S key for the app, resend, and the 401 should go.
This guide is for developers, marketers and agencies who send in-app events to AppsFlyer from a server. Below you will find what the request looks like, a wrong and a fixed example, five causes of an AppsFlyer S2S 401 Unauthorized response with a way to check each one, how it differs from a 200 OK that records nothing, a checklist, and a security note about the key.
The button opens the Attribution Debugger with a sample 401 response. The check runs in your browser and nothing is uploaded.
The server-to-server events API takes a POST request to https://api3.appsflyer.com/inappevent/{app_id}. The app ID goes in the URL path, and the key goes in a header. AppsFlyer’s reference lists the 401 response as Unauthorized, and describes it as the key provided in the authentication header not being the S2S key for this app.
In plain words, AppsFlyer rejected the request before it looked at your event. A 401 says something about the key or the header. It does not say your event data is wrong.
One naming note. AppsFlyer’s API reference calls it the authentication header, and AppsFlyer’s upgrade bulletin for the S2S API calls it the Authorization header. The examples below use authentication, as in the reference. Copy the header name from the AppsFlyer documentation for the endpoint you use.
Here is a request that sends the Dev key. This is the most common wrong key, because AppsFlyer’s bulletin tells you to replace the Dev key with the S2S key when you move to the api3 endpoint:
curl --request POST \
--url https://api3.appsflyer.com/inappevent/com.example.myapp \
--header 'authentication: YOUR_DEV_KEY' \
--header 'content-type: application/json' \
--data '{
"appsflyer_id": "1700000000000-1234567890123456789",
"eventName": "af_login",
"eventValue": ""
}'And the fixed request, with the S2S key for this app in the header and the app ID in the URL path, not in the body:
curl --request POST \
--url https://api3.appsflyer.com/inappevent/com.example.myapp \
--header 'authentication: YOUR_S2S_KEY' \
--header 'content-type: application/json' \
--data '{
"appsflyer_id": "1700000000000-1234567890123456789",
"eventName": "af_login",
"eventValue": ""
}'The app ID, AppsFlyer ID and both keys above are placeholders. Never paste a real key into a post, a chat or a screenshot. For an iOS app, AppsFlyer’s reference says the app ID in the path needs the id prefix, as in id123456789.

The first cause of AppsFlyer S2S 401 Unauthorized below is the one AppsFlyer’s reference names. The others are common causes seen in practice, or follow from AppsFlyer’s token documentation. Where AppsFlyer documents the point, the text says so. The rest are not AppsFlyer statements.
Support: AppsFlyer’s reference describes the 401 as the key not being the S2S key for this app, and the upgrade bulletin says to replace the Dev key with the S2S key.
Fix: put the S2S key in the authentication header.
How to check: look at which key your server code or tool reads. If the value is the key you put in the SDK, it is the wrong one.
Support: common cause, not an AppsFlyer statement. A trailing space or new line is invisible, and it makes the key a different string.
Fix: paste the key again and trim it in your code.
How to check: print the length of the key in your logs, never the key itself, and compare it with the length of the key in AppsFlyer.
Support: AppsFlyer’s reference lists an app_id that does not match the authentication token under its 400 response, so you may see a 400 here instead of a 401. The same check is still worth doing.
Fix: use the S2S key for the same app as the app ID in the path.
How to check: confirm the app ID in the URL, including the id prefix for iOS, and confirm which app the key was set up for.
Support: AppsFlyer’s token article says calls from a deleted token are rejected, and that a new S2S token can take up to 30 minutes to activate and shows as Pending until then.
Fix: use a token that is active. After you create a new one, wait until it stops showing as Pending, and update your server before you delete the old one.
How to check: open the Tokens page in AppsFlyer, which only admins can see, and check that the token your server uses is listed and active.
Support: common cause, not an AppsFlyer statement. A typo in the header name, or a proxy, gateway or wrapper that drops it, means AppsFlyer never sees the key.
Fix: send the header exactly as in AppsFlyer’s documentation, and let it pass through every layer.
How to check: send the same request with cURL straight from your computer. If cURL works and your server does not, something in between changes the header.
A 401 means the request was rejected because of the key. A 200 means AppsFlyer received it. AppsFlyer’s reference says that on receipt only minimum data validation is performed, and that a missing id prefix on an iOS app ID returns a valid 200 without recording the event. So a 200 can still hide a problem, and a 401 is the loud, easy one to fix. Fix the 401 first, then confirm the events show.
id prefix for iOS.AppsFlyer’s token article says to keep your tokens safe because they enable access to your data, and not to publish them in public code repositories. In practice, also keep the key out of client-side code and screenshots, and keep it on your server only. If it leaked, AppsFlyer describes replacing a token this way: create a new one, deploy it, then delete the old one, after which calls from the old token are rejected. Only admins can manage tokens.
Paste the response or error text into the Attribution Debugger, and it explains the likely causes. It reads only what you paste. It cannot see inside your AppsFlyer account and it cannot test your key, so paste the error text, never the key. The check runs in your browser and nothing is uploaded.
If the findings are more than you want to fix yourself, use the buttons under the report to request a written fix plan. For more guides like this one, go back to the debug hub, or read the error 2804066 guide. Sources: AppsFlyer, Server-to-server events API: Send Event, AppsFlyer, Upgrading the S2S API and AppsFlyer, Managing tokens.
The S2S key for this app. AppsFlyer’s reference describes the 401 as the key in the authentication header not being the S2S key for this app.
No, they are different keys. AppsFlyer’s upgrade bulletin tells you to replace the Dev key with the new S2S key in the header when you move to the api3 endpoint.
No. A 401 is about authentication, so AppsFlyer rejected the key before it looked at your event. Data problems are reported separately, for example in the 400 responses AppsFlyer lists.
No. The reference describes the key as being in the authentication header, and the body carries the event. Keep the app ID in the URL path as well.
AppsFlyer’s token article says to open the account menu, choose Security center, and open the AppsFlyer API tokens section. Only admins can view and manage tokens, and S2S tokens can show as Pending for up to 30 minutes after you create them.
AppsFlyer’s bulletin recommends sending a number of test in-app events and checking that no error comes back. Use a test event name, a placeholder AppsFlyer ID format and no customer data, and never paste your key into a tool or a chat.
Built by Al-Fahad Hridoy, an Attribution & Tracking Consultant who fixes Meta Conversions API, WhatsApp click-to-chat, AppsFlyer and Firebase tracking for apps and websites.