Update top-level information

Updating contract attributes

Using the PUT /contracts/{contract_id} endpoint, you can update the top-level attributes of an existing contract.

Currently, you can update the following attributes within the _private object of the request body:

  • name
  • value
  • signing_period_expiration.

🚧

Note:

If you run the PUT request with an empty request body,{} or {"_private": {}}, the contract won't be updated.

Contract name

When updating the name attribute, pay attention to the following:

A PUT request with "_private": {"name": ""} will remove the contract name and will leave the other attributes unchanged.

📘

Note:

You can update the name attribute of a contract in the draft, pending, and signed states.

Contract value

A PUT request with "_private": { "value": null} will remove the contract value and will leave the other attributes unchanged.

📘

Note:

You can update the value attribute of a contract in the draft, pending, and signed states.

Contract signing_period_expiration

There are three options available for signing_period_expiration:

  • never
  • days_after_publish
  • fixed_date.

🚧

Note:

You can update the signing_period_expiration attribute of a contract with the draft state. However,
it is also possible to partially update a contract in the pending state: once the contract has been published, thesigning_period_expiration attribute can be set to never or fixed_date.
When the contract is signed, the signing_period_expiration cannot be updated.

Unlike name and value attributes, where you can use an empty string {""} or null to remove the current attribute value, to change the signing_period_expiration attribute, you need to specify the type attribute.

❗️

Note:

Sending "signing_period_expiration": null will result in an error.

Step 1. Obtain necessary information

In this tutorial, we will update all three top-level attributes described above:

  • name
  • value
  • signing_period_expiration.

To run the script described in this step, 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.
Path parameters
CONTRACT_ID The unique ID of the contract where you want to add a new participant. You can find the contract ID using the contracts endpoint.
Private
_private [object]
name The desired name of the existing contract. See Contract name.
Signing period expiration
signing_period_expiration[object] See Contract signing_period_expiration.
type Specify one of the three available types: never, days_after_publish, or fixed_date.
never If you select the never type, the contract will have no expiration date.
days_after_publish If you selected the days_after_publish type, the contract will be available for signing after the specified number of days after it has been published. You will need to specify the desired expire_days_after_publish along with this type (see the code example below).
fixed_date If you selected the fixed_date type, the contract will be valid for signing till the specified day. You will need to indicate the desired expire_days_after_publish along with this type (see the code example below).
value[object]
amount Specify the desired contract value (see the code example below). See also Contract value.

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 PUT \
     --url https://api.oneflow.com/v1/contracts/10015 \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'x-oneflow-api-token: 9841f1ee533681c3ea6a438560f2bb6c73b76675' \
     --header 'x-oneflow-user-email: [email protected]' \
     --data '
{
     "_private": {
          "name": "Support Agreement - Company AB",
          "signing_period_expiration": {
               "type": "days_after_publish",
               "expire_days_after_publish": 21
          },
          "value": {
               "amount": "500.10"
          }
     }
}
import requests

url = "https://api.oneflow.com/v1/contracts/10015"

payload = {"_private": {
        "name": "Support Agreement - Company AB",
        "signing_period_expiration": {
            "type": "days_after_publish",
            "expire_days_after_publish": 21
        },
        "value": {"amount": "500.10"}
    }}
headers = {
    "Accept": "application/json",
    "x-oneflow-api-token": "9841f1ee533681c3ea6a438560f2bb6c73b76675",
    "x-oneflow-user-email": "[email protected]",
    "Content-Type": "application/json"
}

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

print(response.text)

Expected response

{
  "_links": {
    "data_fields": {
      "href": "https://api.oneflow.com/v1/contracts/10015/data_fields"
    },
    "events": {
      "href": "https://api.oneflow.com/v1/contracts/10015/events"
    },
    "files": {
      "href": "https://api.oneflow.com/v1/contracts/10015/files"
    },
    "parties": {
      "href": "https://api.oneflow.com/v1/contracts/10015/parties"
    },
    "publish": {
      "href": "https://api.oneflow.com/v1/contracts/10015/publish"
    },
    "self": {
      "href": "https://api.oneflow.com/v1/contracts/10015"
    },
    "template": {
      "href": "https://api.oneflow.com/v1/templates/11111"
    },
    "template_type": {
      "href": "https://api.oneflow.com/v1/template_types/12222"
    },
    "workspace": {
      "href": "https://api.oneflow.com/v1/workspaces/12345"
    }
  },
  "_permissions": {
    "contract:delete": true
  },
  "_private": {
    "name": "Support Agreement - Company AB",
    "signing_period_expiration": {
      "type": "days_after_publish",
      "expire_days_after_publish": 21
    },
    "value": {
      "amount": "500.10",
      "currency": "SEK"
    },
    "workspace_id": 12345
  },
  ...
}

Response codes

StatusMeaningDescription
200OKReturns the contract with the created party.
400Bad RequestInvalid format or content of the request.
401UnauthorizedThe API token or the user email is invalid.
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.