Skip to Content
POST/api/v3/validate-authcode

Validate Auth Code

This API allows you to exchange an auth code for an access token.

USE CASE

Get the access_token that authenticates every later API request, right after login completes.

Note

FYERS API access tokens expire daily at 6:30 AM. Generate a new token after 6:30 AM for it to remain valid throughout the day.

Details

  • Send a POST request with a JSON body containing grant_type (authorization_code), appIdHash and code, the auth_code from the login redirect.
  • appIdHash is the SHA-256 hash of app_id:app_secret; keep the app_secret private and never share it.
  • Use the returned access_token for all later requests, sent as app_id:access_token in the Authorization header.
  • If a token is expired or invalid, API calls return error code -8, -15, -16 or -17. See API Error Codes.

Request Attributes

AttributeData TypeDescription
grant_typestringThis value must always be “authorization_code
appIdHashstringSHA-256 of api_id + app_secret
Eg: SHA-256 of app_id:app_secret is
7c7120d2b5004f8de22d8dc2da0453b4d7e6211e37a4108b8371266ecff00498
You can use this online tool for reference
codestringThis is the auth_code which is received from the first step

Response Attributes

AttributeData TypeDescription
sstringok / error
codeintThis is the code to identify specific responses
messagestringThis is the message to identify the specific error responses
access_tokenstringThis value will be used for all the subsequent requests.
Last updated on