{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Error Handling","description":"Sprinklr offers robust, convenient, and simple RESTful Web service APIs to integrate data from Sprinklr to any external system.","keywords":["Sprinklr API","Sprinklr Developer Portal","OAuth 2.0","RESTful API","Social Media API","Customer Experience API","Unified-CXM","Social Listening API"]},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"error-handling","__idx":0},"children":["Error Handling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When things go wrong with your API requests (and they will), the Sprinklr API gives you detailed information about what happened and how to fix it. This guide shows you how to handle errors gracefully and build resilient integrations."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"why-error-handling-matters","__idx":1},"children":["Why error handling matters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No integration is perfect. Networks fail, credentials expire, users request resources that don't exist, and rate limits get hit. The difference between a good integration and a great one is how it handles these situations."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Bad error handling:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your application crashes"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Users see cryptic error messages"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You have no idea what went wrong"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The same error keeps happening"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Good error handling:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your application stays running"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Users get helpful messages"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Errors are logged for debugging"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your code automatically recovers when possible"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Let's build good error handling."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"how-sprinklr-api-errors-work","__idx":2},"children":["How Sprinklr API errors work"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every error response from the Sprinklr API follows the same structure, making it easy to handle errors consistently across your application."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"error-response-anatomy","__idx":3},"children":["Error response anatomy"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"NOT_FOUND\",\n      \"message\": \"Account with ID 600057112 not found\",\n      \"field\": \"accountId\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Let's break this down:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["success: false"]}]}," ","This tells you immediately that something went wrong. Check this field before trying to access data."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["errors"]}," array"]}," ","Contains one or more error objects. You might get multiple errors if several things went wrong (e.g., multiple invalid parameters)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["code"]}]}," ","A machine-readable error code you can programmatically handle. Always the same for a given error type."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["message"]}]}," ","A human-readable explanation of what went wrong. Good for logging and debugging."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["field"]}," (optional)"]}," ","When an error relates to a specific request parameter, this tells you which one. Useful for validation errors."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"http-status-codes","__idx":4},"children":["HTTP status codes"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The API also uses standard HTTP status codes to categorize errors:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Status"},"children":["Status"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"What it means"},"children":["What it means"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Your action"},"children":["Your action"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["200"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["OK"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Request succeeded"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Process the data"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["201"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Created"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource created"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Process the new resource"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["400"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bad Request"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invalid parameters"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Fix your request"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["401"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Unauthorized"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Authentication failed"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check credentials"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["403"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Forbidden"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["No permission"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check access rights"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["404"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Not Found"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource doesn't exist"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Verify the ID"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["429"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Too Many Requests"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Rate limited"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Slow down, retry later"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["500"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Server Error"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sprinklr error"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Retry after delay"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["503"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Service Unavailable"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Temporary outage"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Retry with backoff"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"common-errors-and-how-to-fix-them","__idx":5},"children":["Common errors and how to fix them"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"invalid_parameter---you-sent-bad-data","__idx":6},"children":["INVALID_PARAMETER - You sent bad data"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This happens when a parameter is missing, malformed, or invalid."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"INVALID_PARAMETER\",\n      \"message\": \"accountId must be a valid Sprinklr account ID\",\n      \"field\": \"accountId\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Common causes:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Typo in parameter name"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Wrong\n{ accoundId: \"600057112\" }  // Typo: \"accound\"\n\n// ✅ Correct\n{ accountId: \"600057112\" }\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Wrong data type"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Wrong\n{ accountId: 600057112 }  // Number instead of string\n\n// ✅ Correct\n{ accountId: \"600057112\" }  // String\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Invalid format"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Wrong\n{ startTime: \"2026-02-11\" }  // Missing time and timezone\n\n// ✅ Correct\n{ startTime: \"2026-02-11T00:00:00Z\" }  // Full ISO 8601\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Missing required parameter"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Wrong - missing accountId\nGET /api/v3/account\n\n// ✅ Correct\nGET /api/v3/account?accountId=600057112\n","lang":"javascript"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["How to fix it:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check the error's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["field"]}," property to see which parameter is wrong"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Verify the parameter name spelling"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check the API reference for the correct data type and format"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Validate your data before sending the request"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"not_found---the-resource-doesnt-exist","__idx":7},"children":["NOT_FOUND - The resource doesn't exist"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ID you requested doesn't exist or you don't have access to it."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"NOT_FOUND\",\n      \"message\": \"Account with ID 999999999 not found\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Common causes:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Wrong ID"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Copy-paste error"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ID from a different environment (dev vs production)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Old ID from a deleted resource"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Resource was deleted"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The account was removed from Sprinklr"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The case was archived"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The message was deleted"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["No access to the resource"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["It belongs to a different Sprinklr instance"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your credentials don't have permission"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["It's in a workspace you can't access"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["How to fix it:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Double-check the ID is correct"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Verify the resource exists in your Sprinklr dashboard"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check you're using the right environment (QA vs Production)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Confirm your credentials have access to this resource"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Handling NOT_FOUND gracefully:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function getAccountSafely(accountId) {\n  try {\n    const response = await getAccount(accountId);\n    return response.data;\n  } catch (error) {\n    if (error.code === 'NOT_FOUND') {\n      console.log(`Account ${accountId} doesn't exist or was deleted`);\n      return null;  // Return null instead of crashing\n    }\n    throw error;  // Re-throw other errors\n  }\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"unauthorized---authentication-failed","__idx":8},"children":["UNAUTHORIZED - Authentication failed"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your credentials are missing, expired, or invalid."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"UNAUTHORIZED\",\n      \"message\": \"Invalid or missing authentication token\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Common causes:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Forgot to include credentials"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# ❌ Missing headers\ncurl \"https://api-v3.sprinklr.com/api/v3/account?accountId=123\"\n\n# ✅ Correct\ncurl \"https://api-v3.sprinklr.com/api/v3/account?accountId=123\" \\\n  -H \"Authorization: Bearer YOUR_TOKEN\" \\\n  -H \"Key: YOUR_API_KEY\"\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Typo in credentials"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Extra space in the token"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Missing ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Bearer"]}," prefix"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Copied partial token"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Expired token"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Access tokens can expire"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Generate a new one in Sprinklr settings"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Token was revoked"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Someone regenerated the token"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Admin revoked your access"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["How to fix it:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Verify both Authorization and Key headers are present"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check for typos (especially spaces or line breaks)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ensure the Bearer prefix is there: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Bearer YOUR_TOKEN"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Try generating a new access token"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Test with a simple request to isolate the issue"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Prevention:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Store credentials in environment variables\nconst ACCESS_TOKEN = process.env.SPRINKLR_ACCESS_TOKEN;\nconst API_KEY = process.env.SPRINKLR_API_KEY;\n\n// Validate before making requests\nif (!ACCESS_TOKEN || !API_KEY) {\n  throw new Error('Missing Sprinklr credentials');\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"forbidden---permission-denied","__idx":9},"children":["FORBIDDEN - Permission denied"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your credentials are valid, but you don't have permission for this operation."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"FORBIDDEN\",\n      \"message\": \"You do not have permission to access this resource\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Common causes:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Accessing another account's data"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The account ID belongs to a different Sprinklr instance"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You're trying to access a competitor's data (obviously won't work!)"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Missing permissions"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your Sprinklr user lacks the required role"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The endpoint requires Admin access"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your API credentials have restricted scope"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Environment mismatch"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Using production credentials against QA"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Using QA credentials against production"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["How to fix it:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Verify the resource belongs to your Sprinklr instance"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Contact your Sprinklr admin to check your permissions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Confirm you're using credentials from the right environment"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check if the endpoint requires special permissions"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The difference between 401 and 403:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["401 UNAUTHORIZED"]},": \"I don't know who you are\" (authentication problem)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["403 FORBIDDEN"]},": \"I know who you are, but you can't do that\" (authorization problem)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"rate_limit_exceeded---too-many-requests","__idx":10},"children":["RATE_LIMIT_EXCEEDED - Too many requests"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You've made too many API calls in a short time period."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"RATE_LIMIT_EXCEEDED\",\n      \"message\": \"You have exceeded the rate limit. Please try again in 60 seconds.\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Why rate limits exist:"]}," ","Rate limits ensure fair usage and protect the API infrastructure. Without them, one misbehaving integration could slow down the API for everyone."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["What to do when rate limited:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Stop making requests immediately"]}," ","Don't keep retrying - you'll just stay rate limited longer"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Check the Retry-After header"]}," ","The response includes a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Retry-After"]}," header telling you how long to wait"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Implement exponential backoff"]}," ","Wait progressively longer between retries"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Optimize your integration"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use batch endpoints (50 resources at once)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Cache frequently accessed data"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reduce polling frequency"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Handling rate limits properly:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function fetchWithRateLimit(fetchFunction) {\n  const maxRetries = 3;\n  let retries = 0;\n\n  while (retries < maxRetries) {\n    try {\n      return await fetchFunction();\n    } catch (error) {\n      if (error.code === 'RATE_LIMIT_EXCEEDED') {\n        retries++;\n\n        if (retries >= maxRetries) {\n          throw new Error('Rate limit exceeded after max retries');\n        }\n\n        // Exponential backoff: 2^retry seconds\n        const waitTime = Math.pow(2, retries) * 1000;\n        console.log(`Rate limited. Waiting ${waitTime}ms before retry ${retries}/${maxRetries}`);\n\n        await new Promise(resolve => setTimeout(resolve, waitTime));\n      } else {\n        throw error;  // Not a rate limit error, re-throw\n      }\n    }\n  }\n}\n\n// Usage\nconst account = await fetchWithRateLimit(() => getAccount('600057112'));\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/rate-limiting"},"children":["Rate Limiting guide"]}," for more strategies."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"validation_error---data-validation-failed","__idx":11},"children":["VALIDATION_ERROR - Data validation failed"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The data you sent doesn't meet the API's requirements."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"VALIDATION_ERROR\",\n      \"message\": \"Subject must be between 1 and 500 characters\",\n      \"field\": \"subject\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Common validation errors:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["String too long"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Subject is 600 characters\n{ subject: \"A\".repeat(600) }\n\n// ✅ Within 500 character limit\n{ subject: \"Customer inquiry about pricing\" }\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Invalid email format"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Invalid email\n{ email: \"not-an-email\" }\n\n// ✅ Valid email\n{ email: \"customer@example.com\" }\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Required field missing"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Missing required fields\n{ priority: \"HIGH\" }\n\n// ✅ All required fields present\n{ subject: \"Issue\", priority: \"HIGH\", customerId: \"123\" }\n","lang":"javascript"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["How to prevent validation errors:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"function validateCaseData(data) {\n  const errors = [];\n\n  if (!data.subject || data.subject.length === 0) {\n    errors.push('Subject is required');\n  }\n\n  if (data.subject && data.subject.length > 500) {\n    errors.push('Subject must be 500 characters or less');\n  }\n\n  if (!['LOW', 'MEDIUM', 'HIGH', 'URGENT'].includes(data.priority)) {\n    errors.push('Priority must be LOW, MEDIUM, HIGH, or URGENT');\n  }\n\n  if (errors.length > 0) {\n    throw new Error(`Validation failed: ${errors.join(', ')}`);\n  }\n\n  return true;\n}\n\n// Use before making API call\nvalidateCaseData(caseData);\nconst result = await createCase(caseData);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"server_error---something-went-wrong-on-sprinklrs-side","__idx":12},"children":["SERVER_ERROR - Something went wrong on Sprinklr's side"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The API encountered an internal error. This is rare but does happen."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"success\": false,\n  \"errors\": [\n    {\n      \"code\": \"SERVER_ERROR\",\n      \"message\": \"An internal server error occurred. Please try again later.\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["What to do:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Don't panic"]}," - This isn't your fault"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Retry the request"]}," - It might succeed the second time"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use exponential backoff"]}," - Don't hammer the API"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Log the error"]}," - Include the timestamp and request details"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Contact support"]}," - If it persists, report it with your logs"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Handling server errors:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"async function fetchWithRetry(fetchFunction, maxRetries = 3) {\n  for (let i = 0; i < maxRetries; i++) {\n    try {\n      return await fetchFunction();\n    } catch (error) {\n      const isServerError = error.status >= 500;\n      const isLastRetry = i === maxRetries - 1;\n\n      if (isServerError && !isLastRetry) {\n        const waitTime = Math.pow(2, i) * 1000;\n        console.log(`Server error. Retrying in ${waitTime}ms...`);\n        await new Promise(resolve => setTimeout(resolve, waitTime));\n      } else {\n        throw error;\n      }\n    }\n  }\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"building-robust-error-handling","__idx":13},"children":["Building robust error handling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here's a complete example of production-ready error handling:"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"comprehensive-error-handler","__idx":14},"children":["Comprehensive error handler"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"class SprinklrError extends Error {\n  constructor(code, message, statusCode, field = null) {\n    super(message);\n    this.name = 'SprinklrError';\n    this.code = code;\n    this.statusCode = statusCode;\n    this.field = field;\n  }\n}\n\nasync function callSprinklrAPI(fetchFunction) {\n  try {\n    const response = await fetchFunction();\n\n    if (response.success) {\n      return response.data;\n    } else {\n      // API returned errors\n      const error = response.errors[0];\n      throw new SprinklrError(\n        error.code,\n        error.message,\n        response.status,\n        error.field\n      );\n    }\n  } catch (error) {\n    // Network error or HTTP error\n    if (error instanceof SprinklrError) {\n      throw error;  // Already a Sprinklr error\n    }\n\n    // Handle HTTP errors\n    if (error.response) {\n      const { status, data } = error.response;\n      const apiError = data.errors?.[0] || {};\n\n      throw new SprinklrError(\n        apiError.code || 'UNKNOWN_ERROR',\n        apiError.message || 'An error occurred',\n        status,\n        apiError.field\n      );\n    }\n\n    // Network error (no response from server)\n    throw new SprinklrError(\n      'NETWORK_ERROR',\n      'Failed to connect to Sprinklr API',\n      0\n    );\n  }\n}\n\n// Usage with specific error handling\nasync function getAccountWithErrorHandling(accountId) {\n  try {\n    return await callSprinklrAPI(() => getAccount(accountId));\n  } catch (error) {\n    switch (error.code) {\n      case 'NOT_FOUND':\n        console.log(`Account ${accountId} not found`);\n        return null;\n\n      case 'UNAUTHORIZED':\n        console.error('Authentication failed - check credentials');\n        throw error;\n\n      case 'RATE_LIMIT_EXCEEDED':\n        console.log('Rate limited - waiting before retry');\n        await new Promise(resolve => setTimeout(resolve, 5000));\n        return getAccountWithErrorHandling(accountId);  // Retry\n\n      case 'SERVER_ERROR':\n        console.error('Server error - will retry');\n        await new Promise(resolve => setTimeout(resolve, 2000));\n        return getAccountWithErrorHandling(accountId);  // Retry\n\n      default:\n        console.error(`Unexpected error: ${error.code} - ${error.message}`);\n        throw error;\n    }\n  }\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"error-handling-best-practices","__idx":15},"children":["Error handling best practices"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["1. Always check the success field"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Don't assume success\nconst accounts = response.data;\n\n// ✅ Check first\nif (response.success) {\n  const accounts = response.data;\n} else {\n  console.error('Request failed:', response.errors);\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["2. Log errors with context"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"console.error('API Error:', {\n  code: error.code,\n  message: error.message,\n  endpoint: '/api/v3/account',\n  accountId: '600057112',\n  timestamp: new Date().toISOString()\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["3. Don't expose raw errors to users"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// ❌ Don't do this\nalert(error.message);  // Shows technical details to user\n\n// ✅ Do this\nconsole.error('API Error:', error);\nalert('Unable to load account. Please try again.');\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["4. Implement circuit breakers"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"class CircuitBreaker {\n  constructor(threshold = 5, timeout = 60000) {\n    this.failureCount = 0;\n    this.threshold = threshold;\n    this.timeout = timeout;\n    this.state = 'CLOSED';  // CLOSED, OPEN, HALF_OPEN\n    this.nextAttempt = Date.now();\n  }\n\n  async call(fn) {\n    if (this.state === 'OPEN') {\n      if (Date.now() < this.nextAttempt) {\n        throw new Error('Circuit breaker is OPEN');\n      }\n      this.state = 'HALF_OPEN';\n    }\n\n    try {\n      const result = await fn();\n      this.onSuccess();\n      return result;\n    } catch (error) {\n      this.onFailure();\n      throw error;\n    }\n  }\n\n  onSuccess() {\n    this.failureCount = 0;\n    this.state = 'CLOSED';\n  }\n\n  onFailure() {\n    this.failureCount++;\n    if (this.failureCount >= this.threshold) {\n      this.state = 'OPEN';\n      this.nextAttempt = Date.now() + this.timeout;\n    }\n  }\n}\n\n// Usage\nconst breaker = new CircuitBreaker();\nconst account = await breaker.call(() => getAccount('600057112'));\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["5. Monitor and alert on errors"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const errorCounts = new Map();\n\nfunction trackError(error) {\n  const key = error.code;\n  errorCounts.set(key, (errorCounts.get(key) || 0) + 1);\n\n  // Alert if too many errors\n  if (errorCounts.get('RATE_LIMIT_EXCEEDED') > 10) {\n    sendAlert('Too many rate limit errors - check integration');\n  }\n\n  if (errorCounts.get('UNAUTHORIZED') > 3) {\n    sendAlert('Authentication failing - credentials may be expired');\n  }\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"testing-your-error-handling","__idx":16},"children":["Testing your error handling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Don't wait for production to find out your error handling doesn't work. Test it during development:"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"simulate-errors","__idx":17},"children":["Simulate errors"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"// Create a mock API that returns errors\nfunction mockSprinklrAPI(scenario) {\n  const scenarios = {\n    NOT_FOUND: {\n      success: false,\n      errors: [{\n        code: 'NOT_FOUND',\n        message: 'Account not found'\n      }]\n    },\n    RATE_LIMITED: {\n      success: false,\n      errors: [{\n        code: 'RATE_LIMIT_EXCEEDED',\n        message: 'Rate limit exceeded'\n      }]\n    },\n    UNAUTHORIZED: {\n      success: false,\n      errors: [{\n        code: 'UNAUTHORIZED',\n        message: 'Invalid token'\n      }]\n    }\n  };\n\n  return Promise.resolve(scenarios[scenario]);\n}\n\n// Test your error handling\nasync function testErrorHandling() {\n  console.log('Testing NOT_FOUND handling...');\n  try {\n    await handleResponse(await mockSprinklrAPI('NOT_FOUND'));\n  } catch (error) {\n    console.log('✓ NOT_FOUND handled correctly');\n  }\n\n  console.log('Testing RATE_LIMITED handling...');\n  try {\n    await handleResponse(await mockSprinklrAPI('RATE_LIMITED'));\n  } catch (error) {\n    console.log('✓ RATE_LIMITED handled correctly');\n  }\n}\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"quick-reference-all-error-codes","__idx":18},"children":["Quick reference: All error codes"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Code"},"children":["Code"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"HTTP"},"children":["HTTP"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Cause"},"children":["Cause"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Solution"},"children":["Solution"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["INVALID_PARAMETER"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["400"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bad parameter"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check format and type"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["VALIDATION_ERROR"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["400"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Data validation failed"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Fix data values"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["UNAUTHORIZED"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["401"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Auth failed"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check credentials"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FORBIDDEN"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["403"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["No permission"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Check access rights"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NOT_FOUND"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["404"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource missing"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Verify ID exists"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RATE_LIMIT_EXCEEDED"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["429"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Too many requests"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Implement backoff"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SERVER_ERROR"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["500"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sprinklr error"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Retry with delay"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SERVICE_UNAVAILABLE"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["503"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Temporary outage"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Retry with backoff"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":19},"children":["Next steps"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now that you understand error handling:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/rate-limiting"},"children":["Learn about rate limiting"]}]}," - Avoid rate limit errors"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/best-practices"},"children":["Follow best practices"]}]}," - Build resilient integrations"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/support"},"children":["Get support"]}]}," - Get help when you're stuck"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"getting-help","__idx":20},"children":["Getting help"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you're encountering errors you can't resolve:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/support"},"children":["Support & FAQ"]}]}," - Common issues and solutions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Email support"]}," - api-support@sprinklr.com with error logs"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Include details"]}," - Error code, full error message, request details, timestamp"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Remember: Good error handling is what separates hobby projects from production-ready integrations. Take the time to handle errors properly, and your future self will thank you."]}]},"headings":[{"value":"Error Handling","id":"error-handling","depth":1},{"value":"Why error handling matters","id":"why-error-handling-matters","depth":2},{"value":"How Sprinklr API errors work","id":"how-sprinklr-api-errors-work","depth":2},{"value":"Error response anatomy","id":"error-response-anatomy","depth":3},{"value":"HTTP status codes","id":"http-status-codes","depth":3},{"value":"Common errors and how to fix them","id":"common-errors-and-how-to-fix-them","depth":2},{"value":"INVALID_PARAMETER - You sent bad data","id":"invalid_parameter---you-sent-bad-data","depth":3},{"value":"NOT_FOUND - The resource doesn't exist","id":"not_found---the-resource-doesnt-exist","depth":3},{"value":"UNAUTHORIZED - Authentication failed","id":"unauthorized---authentication-failed","depth":3},{"value":"FORBIDDEN - Permission denied","id":"forbidden---permission-denied","depth":3},{"value":"RATE_LIMIT_EXCEEDED - Too many requests","id":"rate_limit_exceeded---too-many-requests","depth":3},{"value":"VALIDATION_ERROR - Data validation failed","id":"validation_error---data-validation-failed","depth":3},{"value":"SERVER_ERROR - Something went wrong on Sprinklr's side","id":"server_error---something-went-wrong-on-sprinklrs-side","depth":3},{"value":"Building robust error handling","id":"building-robust-error-handling","depth":2},{"value":"Comprehensive error handler","id":"comprehensive-error-handler","depth":3},{"value":"Error handling best practices","id":"error-handling-best-practices","depth":3},{"value":"Testing your error handling","id":"testing-your-error-handling","depth":2},{"value":"Simulate errors","id":"simulate-errors","depth":3},{"value":"Quick reference: All error codes","id":"quick-reference-all-error-codes","depth":2},{"value":"Next steps","id":"next-steps","depth":2},{"value":"Getting help","id":"getting-help","depth":2}],"frontmatter":{"seo":{"title":"Error Handling"}},"lastModified":"2026-10-27T09:16:56.933Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/error-handling","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}