{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":477,"path":"api-reference/rest-apis/c_AttachmentAPI.md","title":"Attachment API","bundle":null,"doc_type":null,"release":"australia","body":"\n# Attachment API\n\nThe Attachment API provides endpoints that allow you to upload and query file attachments.\n\nYou can upload or retrieve a single file with each request.\n\nThe Attachment API respects any system limitations on uploaded files, such as maximum file size and allowed attachment types. You can control these settings using the properties **com.glide.attachment.max\\_size**, 1024MB by default, and **glide.attachment.extensions**.\n\n**Note:** The Attachment API accepts all Content-Type values \\(\\*/\\*\\). Specify the file content type when uploading an attachment. The content type is stored with file metadata allowing other tools to correctly identify and parse the file.\n\nThe following video provides more information on the Attachment API:\n\n## Attachment API role requirements\n\nTo create attachments, the user record used to authenticate the HTTP request with ServiceNow must have any roles required to create Attachment \\[sys\\_attachment\\] records. It must also have any roles required to read and write records on the target table, such as the itil role to add attachments to incident records.\n\nBy default there is no single role allowing a user to add attachments. You can create a role to explicitly allow adding attachments, then assign this role to the user account being used to make the request.\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## Attachment - DELETE /now/attachment/\\{sys\\_id\\}\n\nDeletes a specified attachment.\n\n### URL format\n\nVersioned URL: `/api/now/v1/attachment/{sys_id}`\n\nDefault URL: `/api/now/attachment/{sys_id}`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\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\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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|None| |\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|Status code|Description|\n|-----------|-----------|\n|204|Indicates the request ran successfully.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|404|Not found. The requested item wasn't found.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n|Name|Description|\n|----|-----------|\n|None||\n\n### cURL request\n\n```\ncurl \"https://instance.servicenow.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5\" \\\n--request DELETE \\\n--user 'username':'password'\n\n```\n\n```\n\"\"\n```\n\n## Attachment - DELETE /now/attachment/\\{sys\\_id\\}/attributes\n\nDeletes all attributes for an attachment.\n\nAttributes are deleted from the Attachment Attributes \\[sys\\_attachment\\_attribute\\] table.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}/attributes`\n\nDefault URL: `/api/now/attachment/{sys_id}/attributes`\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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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|None| |\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|Status code|Description|\n|-----------|-----------|\n|204|No Content. The attributes were successfully deleted and no content was returned in the response body.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|404|Not found. The requested item wasn't found.|\n\n### Response body parameters \\(JSON or XML\\)\n\n|Name|Description|\n|----|-----------|\n|None||\n\n### cURL request\n\nThis example deletes all attributes from an attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0/attributes\" \\\n--request DELETE \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n\"\"\n```\n\n## Attachment - DELETE /now/attachment/\\{sys\\_id\\}/attributes/\\{attribute\\_key\\}\n\nDeletes a specified attribute from an attachment.\n\nAttributes are deleted from the Attachment Attributes \\[sys\\_attachment\\_attribute\\] table.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}/attributes/{attribute_key}`\n\nDefault URL: `/api/now/attachment/{sys_id}/attributes/{attribute_key}`\n\n### Supported request parameters\n\n<table id=\"table_oxc_cqh_g3c\" 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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\n\n</td></tr><tr><td>\n\nattribute\\_key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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|None| |\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|Status code|Description|\n|-----------|-----------|\n|204|No Content. The attribute was successfully deleted and no content was returned in the response body.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|404|Not found. The requested item wasn't found.|\n\n### Response body parameters \\(JSON or XML\\)\n\n|Name|Description|\n|----|-----------|\n|None||\n\n### cURL request\n\nThis example deletes a specified attribute from an attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0/attributes/example_key\" \\\n--request DELETE \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n\"\"\n```\n\n## Attachment - GET /now/attachment\n\nReturns the metadata for multiple attachments.\n\n### URL format\n\nVersioned URL: `api/now/v1/attachment`\n\nDefault URL: `api/now/attachment`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_query_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nsysparm\\_limit\n\n</td><td>\n\nLimit to be applied on pagination. **Note:** Unusually large `sysparm_limit` values can impact system performance.\n\nData type: String\n\nDefault: 1000\n\n</td></tr><tr id=\"row_sysparm_offset\"><td>\n\nsysparm\\_offset\n\n</td><td>\n\nNumber of records to exclude from the query. Use this parameter to get more records than specified in **sysparm\\_limit** parameter. For example, if **sysparm\\_limit** is set to 500, but there are additional records you want to query, you can specify a **sysparm\\_offset** parameter value of 500 to get the second set of records.Data type: String\n\nDefault: 0\n\n</td></tr><tr><td>\n\nsysparm\\_query\n\n</td><td>\n\nEncoded query. Queries for the Attachment API are relative to the Attachments \\[sys\\_attachment\\] table.For example: **\\(sysparm\\_query=file\\_name=attachment.doc\\)**\n\nThe encoded query provides support for order by. To sort responses based on certain fields, use the ORDERBY and ORDERBYDESC clauses in sysparm\\_query. For example, `sysparm_query=ORDERBYfile_name^ORDERBYDESCtable_Name` orders the results in ascending order by name first, then in descending order by table name.\n\nData type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|Content-Type|Content type of the response. For metadata requests, this is the content type of the metadata, not the content type of the attachment files.|\n|Link|Links to download the attachments.|\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|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n|Name|Description|\n|----|-----------|\n|Returned information depends on the selected attachments.||\n\n### cURL request\n\n```\ncurl \"https://instance.servicenow.com/api/now/attachment?sysparm_limit=1\" \\\n--request GET \\\n--header \"Accept:application/json\" \\\n--user \"username\":\"password\"\n\n```\n\n```\n{\n  \"result\": [\n    {\n      \"table_sys_id\": \"5054b6f8c0a800060056addcf551ecf8\",\n      \"size_bytes\": \"462\",\n      \"download_link\": \"https://instance.service-now.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5/file\",\n      \"sys_updated_on\": \"2009-05-21 04:12:21\",\n      \"sys_id\": \"615ea769c0a80166001cf5f2367302f5\",\n      \"image_height\": \"\",\n      \"sys_created_on\": \"2009-05-21 04:12:21\",\n      \"file_name\": \"blocks.swf\",\n      \"sys_created_by\": \"glide.maint\",\n      \"compressed\": \"true\",\n      \"average_image_color\": \"\",\n      \"sys_updated_by\": \"glide.maint\",\n      \"sys_tags\": \"\",\n      \"table_name\": \"content_block_programmatic\",\n      \"image_width\": \"\",\n      \"sys_mod_count\": \"0\",\n      \"content_type\": \"application/x-shockwave-flash\",\n      \"size_compressed\": \"485\"\n    }\n  ]\n}\n```\n\n## Attachment - GET /now/attachment/\\{sys\\_id\\}\n\nReturns the metadata for the attachment file with a specific sys\\_id value.\n\n### URL format\n\nVersioned URL: `/api/now/v1/attachment/{sys_id}`\n\nDefault URL: `/api/now/attachment/{sys_id}`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|sys\\_id|Sys\\_id of the attachment record for which to retrieve the metadata.|\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|Content-Type|The content type of the response. For metadata requests, this is the content type of the metadata, not the content type of the attachment files.|\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|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|404|Indicates the specified attachment does not exist, or the current user cannot access it.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n|Name|Description|\n|----|-----------|\n|Metadata specific to the specified attachment.||\n\n### cURL request\n\n```\ncurl \"https://instance.servicenow.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5\" \\\n--request GET \\\n--header \"Accept:application/json\" \\\n--user \"username\":\"password\"\n```\n\n```\n{\n  \"result\": {\n    \"table_sys_id\": \"5054b6f8c0a800060056addcf551ecf8\",\n    \"size_bytes\": \"462\",\n    \"download_link\": \"https://instance.service-now.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5/file\",\n    \"sys_updated_on\": \"2009-05-21 04:12:21\",\n    \"sys_id\": \"615ea769c0a80166001cf5f2367302f5\",\n    \"image_height\": \"\",\n    \"sys_created_on\": \"2009-05-21 04:12:21\",\n    \"file_name\": \"blocks.swf\",\n    \"sys_created_by\": \"glide.maint\",\n    \"compressed\": \"true\",\n    \"average_image_color\": \"\",\n    \"sys_updated_by\": \"glide.maint\",\n    \"sys_tags\": \"\",\n    \"table_name\": \"content_block_programmatic\",\n    \"image_width\": \"\",\n    \"sys_mod_count\": \"0\",\n    \"content_type\": \"application/x-shockwave-flash\",\n    \"size_compressed\": \"485\"\n  }\n}\n```\n\n## Attachment - GET /now/attachment/\\{sys\\_id\\}/attributes\n\nRetrieves all attributes for an attachment.\n\nAttributes are retrieved from the Attachment Attributes \\[sys\\_attachment\\_attribute\\] table.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}/attributes`\n\nDefault URL: `/api/now/attachment/{sys_id}/attributes`\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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|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|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|404|Not found. The requested item wasn't found.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table id=\"table_ykm_12b_g3c\"><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\nArray of objects containing a key-value pair for each attribute.Data type: Array\n\n```\n\"result\": [\n  {\n    \"key\": \"example_key\",\n    \"value\": \"example_value\"\n  }\n]\n```\n\n</td></tr><tr><td>\n\nresult.key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\n\n</td></tr><tr><td>\n\nresult.value\n\n</td><td>\n\nAttribute value.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Value\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example retrieves all attributes for the specified attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0/attributes\" \\\n--request GET \\\n--header \"Accept:application/json\" \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n{\n  \"result\": [\n    {\n      \"key\": \"example_key\",\n      \"value\": \"example_value\"\n    },\n    {\n      \"key\": \"another_key\",\n      \"value\": \"another_value\"\n    }\n  ]\n}\n```\n\n## Attachment - GET /now/attachment/\\{sys\\_id\\}/attributes/\\{attribute\\_key\\}\n\nRetrieves a specified attribute from an attachment.\n\nAttributes are retrieved from the Attachment Attributes \\[sys\\_attachment\\_attribute\\] table.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}/attributes/{attribute_key}`\n\nDefault URL: `/api/now/attachment/{sys_id}/attributes/{attribute_key}`\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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\n\n</td></tr><tr><td>\n\nattribute\\_key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|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|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|404|Not found. The requested item wasn't found.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table id=\"table_fvb_gw3_g3c\"><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\nObject containing the key-value pair for the attribute.Data type: Object\n\n```\n\"result\": { \n   \"key\": \"String\",  \n   \"value\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\n\n</td></tr><tr><td>\n\nresult.value\n\n</td><td>\n\nAttribute value.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Value\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example retrieves a specified attribute from an attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0/attributes/example_key\" \\\n--request GET \\\n--header \"Accept:application/json\" \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n{\n  \"result\": {\n    \"key\": \"example_key\",\n    \"value\": \"example_value\"\n  }\n}\n```\n\n## Attachment - GET /now/attachment/\\{sys\\_id\\}/file\n\nReturns the binary file attachment with a specific sys\\_id value.\n\n### URL format\n\nVersioned URL: `/api/now/v1/attachment/{sys_id}/file`\n\nDefault URL: `/api/now/attachment/{sys_id}/file`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|sys\\_id|Sys\\_id of the attachment record from which to return binary data.|\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td>\n\nData format of the response body. For example, use `image/jpeg` or `image/png` to accept JPEG or PNG image files exclusively. To allow all image types, specify `image/*`; to allow any file type, specify `*/*`.Default: \\*/\\*\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|X-Attachment-Metadata|Metadata about the returned file, such as size, name, and file type.|\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|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n|Name|Description|\n|----|-----------|\n|Binary file attachment||\n\n### cURL request\n\n```\ncurl \"https://instance.servicenow.com/api/now/attachment/615ea769c0a80166001cf5f2367302f5/file\" \\\n--request GET \\\n--header \"Accept:*/*\" \\\n--user \"username\":\"password\"\n```\n\n```\nBinary response not shown.\n```\n\n## Attachment - PATCH /now/attachment/\\{sys\\_id\\}\n\nRenames an attachment.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}`\n\nDefault URL: `/api/now/attachment/{sys_id}`\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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Table: Attachment \\[sys\\_attachment\\]\n\nData type: String\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\nfile\\_name\n\n</td><td>\n\nRequired. New name for the attachment.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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr><tr><td>\n\nContent-Type\n\n</td><td id=\"content_type-entry-RESTAPI\">\n\nData format of the request body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|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|Status code|Description|\n|-----------|-----------|\n|204|No Content. The attachment was successfully renamed and no content was returned in the response body.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nerror\n\n</td><td>\n\nError information. This parameter is only returned if the request failed.Data type: Object\n\n```\n\"error\": {   \n   \"detail\": \"String\",\n   \"message\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nerror.detail\n\n</td><td>\n\nAdditional details about why the request failed.Data type: String\n\n</td></tr><tr><td>\n\nerror.message\n\n</td><td>\n\nError message containing the reason the request failed.Data type: String\n\n</td></tr><tr><td>\n\nstatus\n\n</td><td>\n\nStatus of the API request. This parameter is only returned if the request failed so the only possible value is `failure`.Data type: String\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example renames an attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0\" \\\n--request PATCH \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"file_name\\\": \\\"new_attachment_name\\\"        \n}\" \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n\"\"\n```\n\n## Attachment - POST /now/attachment/\\{sys\\_id\\}/attributes\n\nAdds an attribute to a specified attachment.\n\nAttributes are added in the Attachment Attributes \\[sys\\_attachment\\_attribute\\] table.\n\nThis endpoint can be used to add alt text to an attachment.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}/attributes`\n\nDefault URL: `/api/now/attachment/{sys_id}/attributes`\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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\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\nkey\n\n</td><td>\n\nRequired. Key to use for the attribute.Data type: String\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nRequired. Value to use for the attribute.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<table id=\"table_fnw_xy1_g3c\" class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr><tr><td>\n\nContent-Type\n\n</td><td id=\"content_type-entry-RESTAPI\">\n\nData format of the request body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|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|Status code|Description|\n|-----------|-----------|\n|201|Created. The attribute was successfully created.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|404|Not found. The requested item wasn't found.|\n\n### Response body parameters \\(JSON or XML\\)\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\nObject containing the key-value pair for the attribute.Data type: Object\n\n```\n\"result\": { \n   \"key\": \"String\",  \n   \"value\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\n\n</td></tr><tr><td>\n\nresult.value\n\n</td><td>\n\nAttribute value.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Value\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example adds an attribute to an attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0/attributes\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"key\\\": \\\"example_key\\\",  \n  \\\"value\\\": \\\"example_value\\\"\n}\" \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n{\n  \"result\": {\n    \"key\": \"example_key\",\n    \"value\": \"example_value\"\n  }\n}\n```\n\n## Attachment - POST /now/attachment/file\n\nUploads a specified binary file as an attachment to a specified record.\n\n**Note:** The file to attach must be specified after the last parameter in the passed-in request parameter list.\n\n### URL format\n\nVersioned URL: `/api/now/v1/attachment/file`\n\nDefault URL: `/api/now/attachment/file`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n<table class=\"rest_api_query_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ncreation\\_time\n\n</td><td>\n\nCreation date and time of the attachment. Use this parameter to capture attachment creation times when the Now Mobile app is offline and the attachment is uploaded to a record at a later time.\n\nData type: String\n\nDefault: The current date and time.\n\n</td></tr><tr><td>\n\nencryption\\_context\n\n</td><td>\n\nSys\\_id of an encryption context record. Specify this parameter to allow only users with the specified encryption context to access the attachment. For additional information on encryption context records, see [Field Encryption](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/field-encryption.md).Data type: String\n\n Default: File is encrypted using encryption context accessible to the user, otherwise the attached file is not encrypted with any encryption context.\n\n</td></tr><tr><td>\n\nfile\\_name\n\n</td><td>\n\nRequired. Name to give the attachment. Data type: String\n\n</td></tr><tr><td>\n\ntable\\_name\n\n</td><td>\n\nRequired. Name of the table to attach the file to.Data type: String\n\n</td></tr><tr><td>\n\ntable\\_sys\\_id\n\n</td><td>\n\nRequired. Sys\\_id of the record in the table specified in **table\\_name** that you want to attach the file to. Data type: String\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|&lt;String&gt;|Path to the binary file to attach to the specified record.|\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr><tr><td>\n\nContent-Type\n\n</td><td>\n\nContent type of the file to attach, such as image/jpeg or \\*/\\*. This header is mandatory to post file attachments.\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|Location|URL of the new attachment.|\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|Status code|Description|\n|-----------|-----------|\n|201|Indicates the query ran successfully.|\n|400|Indicates that one or more mandatory parameters were missing from the request.|\n|404|Indicates the record specified by the **table\\_name** and **table\\_sys\\_id** parameters does not exist or is not accessible to the current user.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table id=\"table_kbr_qck_llb\"><thead><tr><th>\n\nElement\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nresult\n\n</td><td>\n\nMetadata of the requested attachment.Data type: Object\n\n```\n\"result\": {\n  \"average_image_color\": \"String\",\n  \"compressed\": \"String\", \n  \"content_type\": \"String\",\n  \"created_by_name\": \"String\",\n  \"download_link\": \"String\",\n  \"file_name\": \"String\",\n  \"image_height\": \"String\",\n  \"image_width\": \"String\",\n  \"size_bytes\": \"String\",\n  \"size_compressed\": \"String\",\n  \"sys_created_by\": \"String\",\n  \"sys_created_on\": \"String\",\n  \"sys_id\": \"String\",\n  \"sys_mod_count\": \"String\",\n  \"sys_tags\": \"String\",\n  \"sys_updated_by\": \"String\",\n  \"sys_updated_on\": \"String\",\n  \"table_name\": \"String\",\n  \"table_sys_id\": \"String\",\n  \"updated_by_name\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.average\\_image\\_color\n\n</td><td>\n\nIf the attachment is an image, the sum of all colors.Data type: String\n\nUnit: RGB or number of pixels.\n\n</td></tr><tr><td>\n\nresult.compressed\n\n</td><td>\n\nFlag that indicates whether the attachment file has been compressed.Possible values:\n\n-   true: File has been compressed.\n-   false: File has not been compressed.\n\nData type: String\n\n</td></tr><tr><td>\n\nresult.content\\_type\n\n</td><td>\n\nContent-type of the associated attachment file, such as image or jpeg or application/x-shockwave-flash.Data type: String\n\n</td></tr><tr><td>\n\nresult.created\\_by\\_name\n\n</td><td>\n\nFull name of entity that originally created the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.download\\_link\n\n</td><td>\n\nDownload URL of the attachment on the ServiceNow instance.Data type: String\n\n</td></tr><tr><td>\n\nresult.file\\_name\n\n</td><td>\n\nFile name of the attachment.Data type: String\n\n</td></tr><tr><td>\n\nresult.image\\_height\n\n</td><td>\n\nIf an image file, the height of the image.Data type: String\n\nUnit: Pixels\n\n</td></tr><tr><td>\n\nresult.image\\_width\n\n</td><td>\n\nIf an image file, the width of the image.Data type: String\n\nUnit: Pixels\n\n</td></tr><tr><td>\n\nresult.size\\_bytes\n\n</td><td>\n\nSize of the attachment.Data type: String\n\nUnit: Bytes\n\n</td></tr><tr><td>\n\nresult.size\\_compressed\n\n</td><td>\n\nSize of the compressed attachment file. If the file is not compressed, empty.Data type: String\n\nUnit: Bytes\n\n</td></tr><tr><td>\n\nresult.sys\\_created\\_by\n\n</td><td>\n\nEntity that originally created the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_created\\_on\n\n</td><td>\n\nDate and time that the attachment file was initially saved to the instance.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_id\n\n</td><td>\n\nSys\\_id of the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_mod\\_count\n\n</td><td>\n\nNumber of times the attachment file has been modified \\(uploaded to the instance\\).Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_tags\n\n</td><td>\n\nAny system tags associated with the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_updated\\_by\n\n</td><td>\n\nEntity that last updated the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_updated\\_on\n\n</td><td>\n\nDate and time that the attachment file was last updated.Data type: String\n\n</td></tr><tr><td>\n\nresult.table\\_name\n\n</td><td>\n\nName of the table to which the attachment is associated.Data type: String\n\n</td></tr><tr><td>\n\nresult.table\\_sys\\_id\n\n</td><td>\n\nSys\\_id of the table associated with the attachment.Data type: String\n\n</td></tr><tr><td>\n\nresult.updated\\_by\\_name\n\n</td><td>\n\nFull name of entity that last updated the attachment file.Data type: String\n\n</td></tr></tbody>\n</table>### cURL request\n\n```\ncurl \"https://instance.servicenow.com/api/now/attachment/file?table_name=incident&table_sys_id=d71f7935c0a8016700802b64c67c11c6&file_name=Issue_screenshot\" \\\n--request POST \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type: image/jpeg\" \\\n--user \"username\":\"password\" \\\n--data-binary \"@ location of the file on file system\"\n```\n\n```\n{\n  \"result\": {\n    \"table_sys_id\": \"d71f7935c0a8016700802b64c67c11c6\",\n    \"size_bytes\": \"36597\",\n    \"download_link\": \"https://instance.servicenow.com/api/now/attachment/6ea10fe64f411200adf9f8e18110c739/file\",\n    \"sys_updated_on\": \"2016-01-22 15:14:07\",\n    \"sys_id\": \"6ea10fe64f411200adf9f8e18110c739\",\n    \"image_height\": \"\",\n    \"sys_created_on\": \"2016-01-22 15:14:07\",\n    \"file_name\": \"Issue_screenshot\",\n    \"sys_created_by\": \"admin\",\n    \"compressed\": \"true\",\n    \"average_image_color\": \"\",\n    \"sys_updated_by\": \"admin\",\n    \"sys_tags\": \"\",\n    \"table_name\": \"incident\",\n    \"image_width\": \"\",\n    \"sys_mod_count\": \"0\",\n    \"content_type\": \"image/jpeg\",\n    \"size_compressed\": \"25130\"\n  }\n}\n```\n\n## Attachment - POST /now/attachment/upload\n\nUploads a multipart file attachment.\n\nThe multipart POST method does not accept any parameters. You must specify the table name and record sys\\_id values within the form body. See the cURL example for a sample of a multipart/form-data request.\n\n**Important:** When using multipart POST, ensure that the file content is contained in the final part of the message only. Earlier parts should contain only metadata such as table name and record sys\\_id.\n\n### URL format\n\nVersioned URL: `/api/now/v1/attachment/upload`\n\nDefault URL: `/api/now/attachment/upload`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n|Name|Description|\n|----|-----------|\n|None| |\n\n### 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<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr><tr><td>\n\nContent-Type\n\n</td><td>\n\nContent type of the request. Set this value to multipart/form-data when using the multipart POST method.\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|Location|URL of the new attachment.|\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|Status code|Description|\n|-----------|-----------|\n|201|Indicates the query ran successfully.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|404|Not found. The requested item wasn't found.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table id=\"table_bbj_pfk_llb\"><thead><tr><th>\n\nElement\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nresult\n\n</td><td>\n\nMetadata of the requested attachment.Data type: Object\n\n```\n\"result\": {\n  \"average_image_color\": \"String\",\n  \"compressed\": \"String\", \n  \"content_type\": \"String\",\n  \"created_by_name\": \"String\",\n  \"download_link\": \"String\",\n  \"file_name\": \"String\",\n  \"image_height\": \"String\",\n  \"image_width\": \"String\",\n  \"size_bytes\": \"String\",\n  \"size_compressed\": \"String\",\n  \"sys_created_by\": \"String\",\n  \"sys_created_on\": \"String\",\n  \"sys_id\": \"String\",\n  \"sys_mod_count\": \"String\",\n  \"sys_tags\": \"String\",\n  \"sys_updated_by\": \"String\",\n  \"sys_updated_on\": \"String\",\n  \"table_name\": \"String\",\n  \"table_sys_id\": \"String\",\n  \"updated_by_name\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.average\\_image\\_color\n\n</td><td>\n\nIf the attachment is an image, the sum of all colors.Data type: String\n\nUnit: RGB or number of pixels.\n\n</td></tr><tr><td>\n\nresult.compressed\n\n</td><td>\n\nFlag that indicates whether the attachment file has been compressed.Possible values:\n\n-   true: File has been compressed.\n-   false: File has not been compressed.\n\nData type: String\n\n</td></tr><tr><td>\n\nresult.content\\_type\n\n</td><td>\n\nContent-type of the associated attachment file, such as image or jpeg or application/x-shockwave-flash.Data type: String\n\n</td></tr><tr><td>\n\nresult.created\\_by\\_name\n\n</td><td>\n\nFull name of entity that originally created the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.download\\_link\n\n</td><td>\n\nDownload URL of the attachment on the ServiceNow instance.Data type: String\n\n</td></tr><tr><td>\n\nresult.file\\_name\n\n</td><td>\n\nFile name of the attachment.Data type: String\n\n</td></tr><tr><td>\n\nresult.image\\_height\n\n</td><td>\n\nIf an image file, the height of the image.Data type: String\n\nUnit: Pixels\n\n</td></tr><tr><td>\n\nresult.image\\_width\n\n</td><td>\n\nIf an image file, the width of the image.Data type: String\n\nUnit: Pixels\n\n</td></tr><tr><td>\n\nresult.size\\_bytes\n\n</td><td>\n\nSize of the attachment.Data type: String\n\nUnit: Bytes\n\n</td></tr><tr><td>\n\nresult.size\\_compressed\n\n</td><td>\n\nSize of the compressed attachment file. If the file is not compressed, empty.Data type: String\n\nUnit: Bytes\n\n</td></tr><tr><td>\n\nresult.sys\\_created\\_by\n\n</td><td>\n\nEntity that originally created the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_created\\_on\n\n</td><td>\n\nDate and time that the attachment file was initially saved to the instance.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_id\n\n</td><td>\n\nSys\\_id of the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_mod\\_count\n\n</td><td>\n\nNumber of times the attachment file has been modified \\(uploaded to the instance\\).Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_tags\n\n</td><td>\n\nAny system tags associated with the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_updated\\_by\n\n</td><td>\n\nEntity that last updated the attachment file.Data type: String\n\n</td></tr><tr><td>\n\nresult.sys\\_updated\\_on\n\n</td><td>\n\nDate and time that the attachment file was last updated.Data type: String\n\n</td></tr><tr><td>\n\nresult.table\\_name\n\n</td><td>\n\nName of the table to which the attachment is associated.Data type: String\n\n</td></tr><tr><td>\n\nresult.table\\_sys\\_id\n\n</td><td>\n\nSys\\_id of the table associated with the attachment.Data type: String\n\n</td></tr><tr><td>\n\nresult.updated\\_by\\_name\n\n</td><td>\n\nFull name of entity that last updated the attachment file.Data type: String\n\n</td></tr></tbody>\n</table>### POST multipart mandatory values\n\nWhen sending a multipart POST request to upload a file attachment, include attachment data in the message body, not in the URL parameters. You must specify these values in the message body:\n\n<table id=\"table_p1v_nnj_js\"><thead><tr><th>\n\nValue\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nContent-Type\n\n</td><td>\n\nContent-Type of the file, included in the message body for multipart uploads.**Note:** The Content-Type must be defined within the file portion of the POST message, not within the form data. See the sample POST multipart message for an example of a multipart message.\n\n Data type: String\n\n</td></tr><tr><td>\n\ntable\\_name\n\n</td><td>\n\nName of the table to which you want to attach the file.Data type: String\n\n</td></tr><tr><td>\n\ntable\\_sys\\_id\n\n</td><td>\n\nSys\\_id of the record on the specified table to which you want to attach the file.Data type: String\n\n</td></tr></tbody>\n</table>### cURL request\n\n```\ncurl \"https://instance.servicenow.com/api/now/attachment/upload\" \\\n--request POST \\\n--header \"Accept:application/json\"\\\n--user \"username\":\"password\"\\\n--header \"Content-Type:multipart/form-data\"\\\n -F 'table_name=incident' \\\n -F 'table_sys_id=d71f7935c0a8016700802b64c67c11c6'\\\n -F 'uploadFile=@ location of the file on file system'\n\\\n```\n\n```\n{\n  \"result\": {\n    \"table_sys_id\": \"d71f7935c0a8016700802b64c67c11c6\",\n    \"size_bytes\": \"36597\",\n    \"download_link\": \"https://instance.service-now.com/api/now/attachment/994adbc64f511200adf9f8e18110c796/file\",\n    \"sys_updated_on\": \"2016-02-02 14:00:21\",\n    \"sys_id\": \"994adbc64f511200adf9f8e18110c796\",\n    \"image_height\": \"\",\n    \"sys_created_on\": \"2016-02-02 14:00:21\",\n    \"file_name\": \"banner-CS0001345_v1_1.jpeg\",\n    \"sys_created_by\": \"admin\",\n    \"compressed\": \"true\",\n    \"average_image_color\": \"\",\n    \"sys_updated_by\": \"admin\",\n    \"sys_tags\": \"\",\n    \"table_name\": \"incident\",\n    \"image_width\": \"\",\n    \"sys_mod_count\": \"0\",\n    \"content_type\": \"image/jpeg\",\n    \"size_compressed\": \"25130\"\n  }\n}\n```\n\n## Attachment - PUT /now/attachment/\\{sys\\_id\\}/attributes/\\{attribute\\_key\\}\n\nUpdates the value of an existing attribute for an attachment.\n\nAttributes are updated in the Attachment Attributes \\[sys\\_attachment\\_attribute\\] table.\n\n### URL format\n\nVersioned URL: `/api/now/{api_version}/attachment/{sys_id}/attributes/{attribute_key}`\n\nDefault URL: `/api/now/attachment/{sys_id}/attributes/{attribute_key}`\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\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nsys\\_id\n\n</td><td>\n\nSys\\_id of the attachment.Data type: String\n\nTable: Attachment \\[sys\\_attachment\\]\n\n</td></tr><tr><td>\n\nattribute\\_key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\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\nvalue\n\n</td><td>\n\nRequired. New value for the attribute.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<table id=\"table_fnw_xy1_g3c\" class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-entry-RESTAPI\">\n\nData format of the response body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr><tr><td>\n\nContent-Type\n\n</td><td id=\"content_type-entry-RESTAPI\">\n\nData format of the request body. Supported types: **application/json** or **application/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|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|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|400|Bad Request. A bad request type or malformed request was detected.|\n|404|Not found. The requested item wasn't found.|\n\n### Response body parameters \\(JSON or XML\\)\n\n<table id=\"table_tmm_qw3_g3c\"><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\nObject containing the key-value pair for the attribute.Data type: Object\n\n```\n\"result\": { \n   \"key\": \"String\",  \n   \"value\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.key\n\n</td><td>\n\nAttribute key.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Key\n\n</td></tr><tr><td>\n\nresult.value\n\n</td><td>\n\nAttribute value.Data type: String\n\nTable: Attachment Attributes \\[sys\\_attachment\\_attribute\\]\n\nColumn: Value\n\n</td></tr></tbody>\n</table>### cURL request\n\nThis example updates the value of the `example_key` attribute for the specified attachment.\n\n```\ncurl \"https://instance.service-now.com/api/now/attachment/a3af695b0a0006871b657c200acf62e0/attributes/example_key\" \\\n--request PUT \\\n--header \"Accept:application/json\" \\\n--header \"Content-Type:application/json\" \\\n--data \"{\n  \\\"value\\\": \\\"new_value\\\"\n}\" \\\n--user 'username':'password'\n```\n\nResponse body.\n\n```\n{\n  \"result\": {\n    \"key\": \"example_key\",\n    \"value\": \"new_value\"\n  }\n}\n```\n\n"}}