Introduction

Use the Db2 on Cloud API to access data, view and create database objects, administer, and monitor your Db2 on Cloud service. gTo view previous versions of the REST API documentation, click V1 and V2.

Error handling

This API uses standard HTTP response codes to indicate whether a method completed successfully. A 200 response indicates success. A 400 type response is some sort of failure.

Security

Every request must include the Authorization HTTP header with the value Bearer [access_token]. An access token can be obtained with the /auth/tokens endpoint, and it is used by Db2 on Cloud to identify who you are. Db2 on Cloud negotiates SSL connections using the TLS v1.2 protocol.

If you are using the latest version of cURL, protocol negotiation will
happen automatically using TLS v1.2.
If you are using an older version of cURL, you will need to specify the
`--tlsv1.2` option in your cURL commands.

You can also use the Db2 on Cloud Scaling REST API to schedule, delete or view the status of a scale operation of your Db2 on Cloud instance. See IBM Db2 on Cloud Scaling REST API.

Methods

Request a new access token

Authenticates the user credentials and returns an access token that can be used when invoking the operations.

POST /auth/tokens
Request

User credentials

Response

Token generated after successful authentication.

Status Code

  • Authentication token

  • Invalid credentials

  • Error payload

No Sample Response

This method does not specify any sample responses.

Creates a new authentication policy **ADMIN ONLY**

Creates a new authentication policy which can be used to control password parameters.

POST /auth_policies
Request

Authentication policy

Response

Collection of authentication policies

Status Code

  • Authentication policy created

  • Only administrators can execute this operation

  • Error payload

No Sample Response

This method does not specify any sample responses.

Lists all authentication policies **ADMIN ONLY**

Returns a list of authentication policies.

GET /auth_policies
Request

No Request Parameters

This method does not accept any request parameters.

Response

Policy defining user's password rules.

Status Code

  • List of authentication policies

  • Only administrators can execute this operation

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns an authentication policy **ADMIN ONLY**

Returns an authentication policy.

GET /auth_policies/{id}
Request

Path Parameters

  • policy ID

Response

Policy defining user's password rules.

Status Code

  • Authentication policy

  • Only administrators can execute this operation

  • Policy not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Updates an authentication policy **ADMIN ONLY**

Updates an authentication policy.

PUT /auth_policies/{id}
Request

Path Parameters

  • policy ID

Authentication policy

Response

Policy defining user's password rules.

Status Code

  • Authentication policy

  • Only administrators can execute this operation

  • Policy not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Deletes an existing policy **ADMIN ONLY**

Deletes an existing policy.
Only administratos can delete policies.

DELETE /auth_policies/{id}
Request

Path Parameters

  • ID of the policy to be deleted.

Response

Status Code

  • Policy deleted

  • Removal of this policy is not allowed

  • The policy does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Sets a new password using dswebToken

Sets a new password using the dswebToken obtained from /auth/reset.

PUT /auth/password
Request

New password and dswebToken

Response

Status Code

  • Password changed

  • Invalid or missing new password

  • If dswebToken is missing or invalid

  • Error payload

No Sample Response

This method does not specify any sample responses.

Requests a password reset based on user's email

An email is sent with the password reset link and code. To set a new password, the user can open the link on a web browser, or use the /auth/password endpoint providing the dswebToken. The dswebToken is valid for 12 hours.

POST /auth/reset
Request

User's email address and ID

Response

Status Code

  • Request accepted

  • Invalid or missing email address and userId

  • The user name and email address do not match.

  • Error payload

No Sample Response

This method does not specify any sample responses.

Lists all schemas in the database

Returns a list of schemas.

GET /schemas
Request

No Request Parameters

This method does not accept any request parameters.

Response

Collection of schemas

Status Code

  • List of schemas

  • Error payload

No Sample Response

This method does not specify any sample responses.

Creates a new schema **ADMIN ONLY**

Creates a new schema. Only administrators can create schemas directly. Regular users can create new schemas indirectly by creating a new table or other database object and specifying the name of the new schema where the object will be placed.

POST /schemas
Request

schema information

Response

Status Code

  • Schema created

  • Invalid parameters or schema already exists

  • Only administrators can create schemas directly

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns schema information

Returns schema information.

GET /schemas/{schema_name}
Request

Path Parameters

  • schema name

Response

Status Code

  • Schema information

  • Schema not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Drops an empty schema

Drops an empty schema. An error is returned if the schema contains any objects.

DELETE /schemas/{schema_name}
Request

Path Parameters

  • schema name

Response

Status Code

  • Success

  • Invalid parameters or schema is not empty

  • Not authorized to drop the schema

  • Schema not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Lists tables in a schema

Returns the list of tables in a schema.

GET /schemas/{schema_name}/tables
Request

Path Parameters

  • schema name

Response

Collection of tables

Status Code

  • List of tables

  • Database or schema not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Creates a new table

Creates a new table.

POST /schemas/{schema_name}/tables
Request

Path Parameters

  • schema name

table definition

Response

Includes table definition and statistics. Note that statistics such as row count and size are not updated real time. Check the stats_timestamp value to know how current that information is.

Status Code

  • table info

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns information about a table

Return information about a table.

GET /schemas/{schema_name}/tables/{table_name}
Request

Path Parameters

  • schema name

  • table name

Response

Includes table definition and statistics. Note that statistics such as row count and size are not updated real time. Check the stats_timestamp value to know how current that information is.

Status Code

  • Table information

  • Table not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Drops a table

Drops a table.

DELETE /schemas/{schema_name}/tables/{table_name}
Request

Path Parameters

  • schema name

  • table name

Response

Status Code

  • success

  • Table not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns table data

Fetches the table data up to a maximum of 100,000 rows. Currently it's not possible to retrieve data from tables that contain CLOB, BLOB or DBCLOB values.

GET /schemas/{schema_name}/tables/{table_name}/data
Request

Path Parameters

  • schema name

  • table name

Query Parameters

  • Maximum number of rows to fetch. If ommited, it assumes the value 1000. Valid range is between 1 and 100,000.

    Default: 1000

Response

Status Code

  • table data

  • Invalid parameters or unsupported column data type

  • Not authorized to access table data

  • Table not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Deletes all table data

Deletes all table data using a TRUNCATE operation.

DELETE /schemas/{schema_name}/tables/{table_name}/data
Request

Path Parameters

  • schema name

  • table name

Response

Status Code

  • success

  • Not authorized to access table data

  • Table not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Lists all data load jobs, load uses Db2 load utility technology

Lists all data load jobs for the user.

GET /load_jobs
Request

No Request Parameters

This method does not accept any request parameters.

Response

Information about a data load job

Status Code

  • Data load jobs

  • Error payload

No Sample Response

This method does not specify any sample responses.

Creates a data load job

Creates a data load job

POST /load_jobs
Request

Data load job details

Response

Confirmation of load job created

Status Code

  • load jobs.

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns details about a load job including its progress

Returns details about a load job including its progress.

GET /load_jobs/{id}
Request

Path Parameters

  • Load job ID

Response

Information about a data load job

Status Code

  • Data load job

  • Not authorized to access load job

  • Job not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Removes load job from history

Removes a data load job from history. This operation has no effect on the data already loaded. In-progress jobs cannot be deleted.

DELETE /load_jobs/{id}
Request

Path Parameters

  • Load job ID

Response

Status Code

  • Load job deleted

  • Not authorized to delete load job

  • Job not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Dowloads log file for a data load job

Downloads log file for a data load job

GET /load_jobs/{id}/log
Request

Path Parameters

  • Load job ID

Response

Collection of data load jobs

Status Code

  • Log file

  • Not authorized to access load log

  • Log not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Executes SQL statements

Executes one or more SQL statements as a background job. This endpoint returns a job ID that can be used to retrieve the results.

POST /sql_jobs
Request

SQL script and execution options

Response

Status Code

  • SQL execution job

  • Error payload

No Sample Response

This method does not specify any sample responses.

Fetches partial results of a SQL job execution

Returns the current status of a SQL job execution along with any results of SQL statements that have already been executed. Clients are supposed to poll this endpoint until the status returned is either 'completed', which indicates all SQL statements have completed executing, or 'failed', which indicates the job failed to execute and therefore is considered terminated. The returned list of results is not cumulative. That means, results that were fetched in a previous call will not be returned again, only new results (i.e. that were not fetched yet) will be included. For example, assuming a job with 10 SQL statements, the first call returns status "running" and 6 results, the second call returns status "running" and an empty list of results, a third call status "completed" and 4 results. Any subsequent calls would return status "completed" and an empty list of results.

GET /sql_jobs/{id}
Request

Path Parameters

  • ID of the SQL execution job

Response

Contains the results of executing the SQL statements associated with a SQL execution job

Status Code

  • Result of a SQL job

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns the results of a SQL query to CSV

Executes the specified SQL query and returns the data as a CSV file. The amount of data returned is limited to 100,000 rows.

POST /sql_query_export
Request

The SQL query to be executed

Response

Collection of files or folders metadata

Status Code

  • CSV file containing query results

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns metadata of an item in the user's home storage

Returns metadata of an item files and folders stored in the user's home storage.

GET /home/{path}
Request

Path Parameters

  • Path of a file or folder

Response

Describes a file or folder.

Status Code

  • Metadata about a file or folder

  • File or folder not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Deletes a file in the user's home storage

Deletes a file in the user's home storage

DELETE /home/{path}
Request

Path Parameters

  • File path

Response

Status Code

  • File deleted

  • Error payload

No Sample Response

This method does not specify any sample responses.

Download file from user's home storage

Download file from user's home storage.

GET /home_content/{path}
Request

Custom Headers

  • Allowable values: [application/json,application/octet-stream]

Path Parameters

  • File path

Response

Describes a file or folder.

Status Code

  • Metadata about a file or folder

  • File not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Uploads a file to the user's home storage

Uploads a file to a folder under the user's home storage. The target folder is automatically created if it does not exit.

POST /home_content/{path}
Request

Path Parameters

  • Target folder

Response

Describes a file or folder.

Status Code

  • Files successfully uploaded

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns overall status of system components **ADMIN ONLY**

Returns overall status of system components.

GET /monitor
Request

No Request Parameters

This method does not accept any request parameters.

Response

Services status

Status Code

  • System status

  • Operation is only available to administrators

  • Error payload

No Sample Response

This method does not specify any sample responses.

Lists active database connections **ADMIN ONLY**

Returns a list of active database connections.

GET /monitor/connections
Request

No Request Parameters

This method does not accept any request parameters.

Response

Collection of active database connections

Status Code

  • Active connections

  • Operation is only available to administrators

  • Error payload

No Sample Response

This method does not specify any sample responses.

Terminates a database connection **ADMIN ONLY**

Terminates an active database connection.

DELETE /monitor/connections/{application_handle}
Request

Path Parameters

  • Application handle name

Response

Status Code

  • Connection terminated

  • Operation is only available to administrators

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns current storage usage

Returns current storage usage.

GET /monitor/storage
Request

No Request Parameters

This method does not accept any request parameters.

Response

Status Code

  • Storage usage

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns storage usage history

Returns a list of storage usage daily stats. Currenlty the history of the last seven days is returned.

GET /monitor/storage/history
Request

No Request Parameters

This method does not accept any request parameters.

Response

Collection of system storage stats

Status Code

  • Storage usage history

  • Error payload

No Sample Response

This method does not specify any sample responses.

Storage utilization by schema **ADMIN ONLY**

Returns a list where each element represents a schema and its corresponding logical and physical sizes. Physical size is the amount of storage in disk allocated to objects in the schema. Logical size is the actual object size, which might be less than the physical size (e.g. in the case of a logical table truncation).

GET /monitor/storage/by_schema
Request

No Request Parameters

This method does not accept any request parameters.

Response

Collection of schema's storage usage data

Status Code

  • Storage usage by schema

  • Operation is only available to administrators

  • Error payload

No Sample Response

This method does not specify any sample responses.

Storage utilization of a schema **ADMIN ONLY**

Returns logical and physical sizes for one schema. Physical size is the amount of storage in disk allocated to objects in the schema. Logical size is the actual object size, which might be less than the physical size (e.g. in the case of a logical table truncation).

GET /monitor/storage/by_schema/{schema_name}
Request

Path Parameters

  • schema name

Response

Status Code

  • Storage usage for a schema

  • Operation is only available to administrators

  • Schema does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns the system's current settings

Returns the system's current settings.

GET /settings
Request

No Request Parameters

This method does not accept any request parameters.

Response

A collection of system settings.

Status Code

  • system settings

  • Error payload

No Sample Response

This method does not specify any sample responses.

Updates the system settings **ADMIN ONLY**

The only setting that can be modified is database_ssl_connections_enforced. By setting database_ssl_connections_enforced to true database connection requests must be secured. If set to false both secured and unsecured database connections are accepted. This operation is only available to system administrators.

PUT /settings
Request

System settings

Response

A collection of system settings.

Status Code

  • system settings

  • Error payload

No Sample Response

This method does not specify any sample responses.

Generates a new Aspera token

Aspera is a high-speed file transfer technology that can be used to speed up file uploads to Db2 Warehouse on Cloud. This endpoint generates a new token that must be used when uploading files with Aspera.

POST /aspera
Request

No Request Parameters

This method does not accept any request parameters.

Response

Token generated for Aspera

Status Code

  • Aspera token

  • Error payload

No Sample Response

This method does not specify any sample responses.

Deletes an Aspera token

Deletes an Aspera token. You should delete a token after the upload is complete. Optionally provide the name of a file that was uploaded using Aspera to prepare it for loading.

DELETE /aspera/{token}
Request

Path Parameters

  • Aspera token

Query Parameters

  • Name of file that was uploaded

Response

Status Code

  • Success

  • Token or file not found

  • Error payload

No Sample Response

This method does not specify any sample responses.

Analyzes CSV data to return a list of data types of its values

Schema discovery analyzes data in CSV format and returns a list of suggested data types that can be used when creating a table to store the CSV data.

POST /schema_discovery
Request

Data to analyze

Response

Result of running schema discovery.

Status Code

  • Suggested table schema

  • Error payload

No Sample Response

This method does not specify any sample responses.

Returns the list of users

Administrators can retrieve the list of all users in the system. Regular users will receive a list containing only their own user profile.

GET /users
Request

No Request Parameters

This method does not accept any request parameters.

Response

Collection of users

Status Code

  • List of users

  • Error payload

No Sample Response

This method does not specify any sample responses.

Creates a new user. **ADMIN ONLY**

Creates a new user.
This operation is only available to system administrators.

POST /users
Request

User information

Response

Status Code

  • User response

  • Invalid parameters or user already exists

  • Operation is only available to administrators

  • Error payload

No Sample Response

This method does not specify any sample responses.

Get a specific user by ID

Get a specific user by ID. System administrators may retrieve user information for any user. Regular users may only retrieve themselves.

GET /users/{id}
Request

Path Parameters

  • ID of the user to be fetched

Response

Status Code

  • User response

  • Access to this user is not allowed

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Updates an existing user

Updates an existing user. System administrators may update user information for any user. Regular users may only update themselves.

PUT /users/{id}
Request

Path Parameters

  • ID of the user to be updated

User information

Response

Status Code

  • User response

  • Access to this user is not allowed

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Deletes an existing user **ADMIN ONLY**

Deletes an existing user.
Only administratos can delete users.

DELETE /users/{id}
Request

Path Parameters

  • ID of the user to be deleted.

Response

Status Code

  • User deleted

  • Removal of this user is not allowed

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Locks a user account indefinitely. **ADMIN ONLY**

Admin users can unlock users' accounts which have been locked out following repeated failed authentication attempts.

PUT /users/{id}/lock
Request

Path Parameters

  • ID of the user who will be locked

Response

Status Code

  • User response

  • Cannot edit this user

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Unlocks a user account **ADMIN ONLY**

Admin users can unlock users' accounts which have been locked out following repeated failed authentication attempts.

PUT /users/{id}/unlock
Request

Path Parameters

  • ID of the user who will be unlocked

Response

Status Code

  • User response

  • Cannot edit this user

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Get a specific user's connection privileges

Get a specific user's connection privileges. If restricted is set to 'yes', the user will only be allowed to make database connections from IP addresses or hostnames in the authorized_hosts list. System administrators may retrieve connection privilege information for any user. Regular users may only retrieve their own connection privileges.

GET /users/{id}/connection_privileges
Request

Path Parameters

  • ID of the user who's information is to be fetched

Response

Status Code

  • User's connection privileges

  • Access to this user's connection privileges is not allowed

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.

Updates an existing user's connection privileges **ADMIN ONLY**

Updates an existing user's connection privileges. If restricted is set to 'yes', the user will only be allowed to make database connections from IP addresses or hostnames in the authorized_hosts list. This operation is only available to system administrators. An administrator may set the privileges of all users other than themself.

PUT /users/{id}/connection_privileges
Request

Path Parameters

  • ID of the user who's information is to be updated

Connection privilege information

Response

Status Code

  • Updated user connection privileges

  • Access to this user's connection privileges is not allowed

  • The user does not exist

  • Error payload

No Sample Response

This method does not specify any sample responses.