Skip to content

Upload a file and use as Attachment to Subclient

This guide combines examples described in the API documentation in these places:

Prerequisites

The code snippets provided in this scenario require the following variables:

  • BASE_API_URL - The target GIB API domain, which can be found in the API-Reference.
  • API_KEY - The API key setup by the client for using the API. Can be generated using the Dashboard.
  • SUBCLIENT_ID - The ID for the target Subclient that the attachment is for

Step 1 - Upload the file

See File Upload

Step 2 - Add as Attachment

Use the same URL from Step 1 again as the url in the POST data for the Create Subclient Attachment endpoint.

Maximum file size

An attachment file must not exceed 50 MB. Larger files are rejected when the attachment is created, not during the upload in Step 1.

url = f"{BASE_API_URL}/subclient/{SUBCLIENT_ID}/attachment"

payload = {
    "category_and_type": {
        "category": "natural_person_identification",
        "type": "passport"
    },
    "description": "John Doe's Passport Scan (File)",
    "active": True,
    "url": upload_url,
    "file_name_original": "passport_johndoe.pdf",
    "file_extension": content_type,
    "file_create_date_time": "2022-08-15T00:00:00.000Z"
}
headers = {
    "content-type": "application/json",
    "Authorization": f"{API_KEY}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)