{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":456,"path":"api-reference/rest-apis/agent-mapping-api.md","title":"Agent Mapping API","bundle":null,"doc_type":null,"release":"australia","body":"\n# Agent Mapping API\n\nThe Agent Mapping API provides an endpoint to map external agent IDs from Contact Center as a Service \\(CCaaS\\) systems to internal agent IDs in the ServiceNow AI Platform.\n\nThis API requires the External Agent Management Util Pack \\(sn\\_external\\_agent\\) plugin. To call this API, you must have the interaction\\_agent role.\n\nFor more information about integrating with CCaaS systems, see [Integrating with contact centers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/customer-service-management/contactcenter-integration.md).\n\n**Parent Topic:**[REST API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/api-rest.md)\n\n## Agent Mapping - PUT /sn\\_ct\\_ctr\\_it\\_core/agent\\_mapping/agent/\\{agentId\\}/inboundId/\\{inboundId\\}\n\nMaps an external agent ID from a Contact Center as a Service \\(CCaaS\\) system to an internal agent ID in the ServiceNow AI Platform.\n\nCall this endpoint when an agent logs in or out of the CCaaS system to update their active status. This endpoint creates or updates records in the External Agent Mapping \\[external\\_agent\\_mapping\\] table with the following data:\n\n-   External CCaaS agent ID\n-   Provider channel identity associated with the inbound ID\n-   Agent's active status in the CCaaS system\n-   Reference to the User \\[sys\\_user\\] record for the agent\n\n### URL format\n\nDefault URL: `/api/sn_ct_ctr_it_core/agent_mapping/agent/{agentId}/inboundId/{inboundId}`\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nagentId\n\n</td><td>\n\nSys\\_id of the internal agent.Data type: String\n\nTable: User \\[sys\\_user\\]\n\n</td></tr><tr><td>\n\ninboundId\n\n</td><td>\n\nInbound ID from the provider channel identity record for the CCaaS system.Data type: String\n\nTable: Provider Channel Identity \\[sys\\_cs\\_provider\\_application\\]\n\nField: Inbound ID\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_request_body\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nactive\n\n</td><td>\n\nFlag that indicates whether the agent is currently logged in to the CCaaS system.Valid values:\n\n-   true: The agent is logged in.\n-   false: The agent is logged out.\n\nDefault: true\n\nData type: Boolean\n\n</td></tr><tr><td>\n\nexternal\\_agent\\_id\n\n</td><td>\n\nRequired. External agent ID from the CCaaS system.Data type: String\n\n</td></tr></tbody>\n</table>### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Header|Description|\n|------|-----------|\n|Accept|Data format of the response body. Only supports **application/json**.|\n|Content-Type|Data format of the request body. Only supports **application/json**.|\n\n|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table><thead><tr><th>\n\nStatus code\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\n200\n\n</td><td>\n\nOK. Existing agent mapping record updated.\n\n</td></tr><tr><td>\n\n201\n\n</td><td>\n\nCreated.New agent mapping record created.\n\n</td></tr><tr><td>\n\n400\n\n</td><td>\n\nBad request.The agent ID or inbound ID provided in the request is invalid.\n\n</td></tr></tbody>\n</table>### Response body parameters \\(JSON\\)\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nresult\n\n</td><td>\n\nResult object containing information about the request.Data type: Object\n\n</td></tr><tr><td>\n\nresult.mappingIds\n\n</td><td>\n\nSys\\_ids of any created or updated records in the External Agent Mapping \\[external\\_agent\\_mapping\\] table.Data type: Array of strings\n\n</td></tr><tr><td>\n\nresult.message\n\n</td><td>\n\nMessage explaining the outcome of the request.Data type: String\n\n</td></tr><tr><td>\n\nresult.status\n\n</td><td>\n\nStatus of the request.Possible values:\n\n-   Success\n-   Failure\n\nData type: String\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example maps an internal agent with sys\\_id `da419c1fc312310015519f2974d3ae15` to the corresponding ID `12345` from the external CCaaS system.\n\n```\ncurl \"https://instance.service-now.com/api/sn_ct_ctr_it_core/agent_mapping/agent/da419c1fc312310015519f2974d3ae15/inboundId/ServiceNowVoice\" \\ \n--request PUT \\ \n--header \"Accept:application/json\" \\ \n--header \"Content-Type:application/json\" \\ \n--data \"{\\\"external_agent_id\\\":\\\"12345\\\"}\" \\ \n--user 'username':'password'\n```\n\nResponse body:\n\n```\n{\n  \"result\": { \n    \"message\": \"Agent Id mapping record inserted\", \n    \"status\": \"success\", \n    \"mappingIds\": [ \n      \"128b74fcc3931a50325a4ad9d00131c3\" \n    ] \n  } \n}\n```\n\n### cURL request\n\nThis example sets the **active** parameter to `false` to indicate that the agent is logged out of the CCaaS system.\n\n```\ncurl \"https://instance.service-now.com/api/sn_ct_ctr_it_core/agent_mapping/agent/da419c1fc312310015519f2974d3ae15/inboundId/ServiceNowVoice\" \\ \n--request PUT \\ \n--header \"Accept:application/json\" \\ \n--header \"Content-Type:application/json\" \\ \n--data \"{\"external_agent_id\":\"12345\", \"active\":\"false\"}\" \\ \n--user 'username':'password'\n```\n\nResponse body:\n\n```\n{ \n  \"result\": { \n    \"message\": \"Agent Id mapping record updated\", \n    \"status\": \"success\", \n    \"mappingIds\": [ \n      \"cea77cebebef9e10a341fc7acad0cdc2\" \n    ] \n  } \n}\n```\n\n"}}