Publish a contract

This tutorial shows you how to publish a contract in the draft state along with the contract invitation message using the REST API. You will also learn what data elements you’ll need for this and how to obtain them.

🚧

Note:

The contract publishing feature is not available in the free plan. To use this feature, please make sure you are on a paid plan.

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 Your Oneflow user account email. You can find all user-related information using the users endpoint.
Path parameter
CONTRACT_ID The unique ID of the contract you want to get. You can find the contract ID using the contracts endpoint.
Body
subject The subject of the contract invitation message. The invitation is sent to all contract participants according to the delivery channel.
message The message to be displayed under the subject of the contract invitation. The invitation is sent to all contract participants according to the delivery channel.

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 POST \
  --url https://api.oneflow.com/v1/contracts/CONTRACT_ID/publish \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'x-oneflow-api-token: API_TOKEN' \
  --header 'x-oneflow-user-email: USER_EMAIL' \
  --data '{"subject":"Contract invitation subject","message":"Contract invitation message."}'
import requests

payload = {
  'subject': 'Contract invitation subject', 
  'message': 'Contract invitation message.'
}

headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'x-oneflow-api-token': 'API_TOKEN',
    'x-oneflow-user-email': 'USER_EMAIL'
    }

response = requests.post('https://api.oneflow.com/v1/contracts/CONTRACT_ID/publish', 
                         json=payload, headers=headers)

print(response.json())

Expected response

This request will output details about the contract you published in the JSON format.

Response codes

StatusMeaningDescription
200OKReturns the contract.
400Bad RequestInvalid format or content of the request.
401UnauthorizedThe API token or the user email is invalid.
402Payment RequiredThe feature is not available for your current subscription plan.
403ForbiddenThe request is not authorized by the server.
404Not FoundA required entity is missing.
409ConflictA conflict occurred with the current state of the target resource.

Did this page help you?