Delete a contract

Deleting a contract moves it to trash; it is not permanently deleted until the trash is emptied.

You can view deleted contracts in the Oneflow web app by going to Documents > Trash.

❗️

Warning

Be careful when emptying the trash. Once trash is emptied, contracts in the trash are permanently lost and cannot be restored.
Always double-check you are deleting the correct contract by checking its ID.

Step 1. Obtain necessary information

To run the script described in this tutorial, you’ll need the following data:

Headers
x-oneflow-api-token You will only be able to run the script by using a valid API token. You can create an API token in the Oneflow web application. Find out more in the Authentication section.
x-oneflow-user-email The Oneflow user account email on whose behalf you want to move the contract to trash. You can find all user-related information using the users endpoint.
Path parameter
CONTRACT_ID The unique ID of the contract you want to move to trash. You can find the contract ID using the contracts endpoint.

Step 2. Run the code

Replace the values of the parameters in the following command with the actual data from your account and run it.

curl --request DELETE \
  --url https://api.oneflow.com/v1/contracts/CONTRACT_ID \
  --header 'x-oneflow-api-token: API_TOKEN' \
  --header 'x-oneflow-user-email: USER_EMAIL'
import requests

headers = {
    'x-oneflow-api-token': API_TOKEN,
    'x-oneflow-user-email': USER_EMAIL
    }

response = requests.delete('https://api.oneflow.com/v1/contracts/CONTRACT_ID', 
                           headers=headers)

print(response.json())

Expected response

This operation will move the specified contract to trash and display an empty body in the response. You can view contracts in trash from the Oneflow web app by going to Documents > Trash.

Please see the Contract section in the Data model category for more information about the output.

Response codes

StatusMeaningDescription
200OKThe contract was moved to trash successfully. This response is also returned if the contract does not exist.
400Bad RequestInvalid format or content of the request.
401UnauthorizedThe API token or the user email is invalid.


Did this page help you?