Attachment API - POST /now/attachment/upload

This method uploads a multipart file attachment.

URL format

Versioned URL: /api/now/v1/attachment/upload

Default URL: /api/now/attachment/upload

Supported request parameters

Table 1. Parameters
Parameter Description
None The multipart POST method does not accept any parameters. The table name and record sys_id values must be specified within the message body. See the POST multipart sample for an example of a multipart message.
Important: When using multipart POST, ensure 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.


The 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 REST API headers.

Table 2. Request headers
Header Description
Content-Type The content type of the request. Set this value to multipart/form-data when using the multipart POST method.
Table 3. Response headers
Header Description
Location The URL of the new attachment.

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API response codes.

Table 4. Status codes
Status code Description
201 Indicates the query ran successfully.

POST multipart mandatory values

When 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:
Table 5. Mandatory values
Value Description
table_name The name of the table you want to attach the file to.
record_sys_id The sys_id of the record on the specified table that you want to attach the file to.
Content-Type The Content-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.

Sample cURL request

curl "" \
--request POST \
--header "Accept:application/json"
--user 'admin':'admin'"\
--header "Content-Type:multipart/form-data"
 -F 'table_name=incident' -F 'table_sys_id=d71f7935c0a8016700802b64c67c11c6' -F 'encryption_context=undefined'-F 'uploadFile=@ location of the file on file system'
  "result": {
    "table_sys_id": "d71f7935c0a8016700802b64c67c11c6",
    "size_bytes": "36597",
    "download_link": "",
    "sys_updated_on": "2016-02-02 14:00:21",
    "sys_id": "994adbc64f511200adf9f8e18110c796",
    "image_height": "",
    "sys_created_on": "2016-02-02 14:00:21",
    "file_name": "banner-CS0001345_v1_1.jpeg",
    "sys_created_by": "admin",
    "compressed": "true",
    "average_image_color": "",
    "sys_updated_by": "admin",
    "sys_tags": "",
    "table_name": "incident",
    "image_width": "",
    "sys_mod_count": "0",
    "content_type": "image/jpeg",
    "size_compressed": "25130"

Sample Python request

# This example uses the Python Requests Library and you will need to install requests package for python
# Documentation can be found at
import requests
import pprint
import json

# Specify the Endpoint URL replacing instance with your ServiceNow Instance Name
url = ''

# Specify Parameters for File Being Uploaded, the table_name and table_sys_id should be replaced with values that make
# sense for your use case
payload = {'table_name':'incident', 'table_sys_id':'81f8915bdb6ba20028927416bf961971'}

# Specify Files To Send and Content Type. When specifying fles to send make sure you specify the path to the file, in
# this example the file was located in the same directory as the python script being executed.
# it is important to specify the correct file type
files = {'file': ('issue_screenshot.JPG', open('issue_screenshot.JPG', 'rb'), 'image/jpg', {'Expires': '0'})}

# Eg. User name="admin", Password="admin" for this code sample. This will be sent across as basic authentication
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Accept":"*/*"}

# Send the HTTP request
response =, auth=(user, pwd), headers=headers, files=files, data=payload)

# Check for HTTP codes other than 201
if response.status_code != 201:
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())

# Print Resopnse Details
print 'Response Status Code:', response.status_code

print ''
print('Reponse Payload:')
print json.dumps(response.json(), indent=4)
Response Status Code: 201

Reponse Payload:
    "result": {
        "sys_tags": "", 
        "sys_updated_by": "admin", 
        "content_type": "image/jpg", 
        "sys_created_by": "admin", 
        "file_name": "issue_screenshot.JPG", 
        "sys_updated_on": "2017-01-05 10:47:09", 
        "sys_created_on": "2017-01-05 10:47:09", 
        "image_width": "", 
        "image_height": "", 
        "sys_mod_count": "0", 
        "table_name": "incident", 
        "sys_id": "96679f724f84320025e874828110c7bd", 
        "download_link": "", 
        "average_image_color": "", 
        "size_bytes": "197484", 
        "table_sys_id": "'81f8915bdb6ba20028927416bf961971'", 
        "size_compressed": "197005", 
        "compressed": "true"