Search…
Creating a workflow
Learn how to utilize the Workflow API to create custom workflows.
To create a new workflow, you must make a POST request to api.cased.com/workflows with a JSON payload that defines that workflow. If you're using our Terraform provider, the provider takes care of this operation for you. The payload consists of three keys: name, controls, and conditions. A full example:
1
{
2
"name": "provision-database",
3
"conditions": [
4
{
5
"field": "service",
6
"value": "database-service",
7
"operator": "eq"
8
}
9
],
10
"controls": {
11
"authentication": true,
12
"reason": true,
13
"approval": {
14
"count": 1,
15
"self_approval": true,
16
"duration": 1,
17
"timeout": 30,
18
"responders": {
19
"admins": "required",
20
"[email protected]": "optional"
21
},
22
"sources": {
23
"email": true,
24
"slack": {
25
"channel": "#database-ops",
26
"fields": ["command", "reason"]
27
}
28
},
29
"oncalls": {
30
"pagerduty": "Default",
31
}
32
}
33
}
34
}
Copied!
  • name Required
    • The string name of this workflow. Cannot contain spaces.
  • controls Required
    • An object that details the requirements and logic that make up this workflow.
    • Object keys:
      • authentication
        • boolean
        • Whether or not the user must be authenticated when submitting an event.
      • reason
        • boolean
        • Whether or not a reason for approval request is required when submitting an event.
      • approval
        • object
        • Detailed settings for the approval workflow.
        • Object keys:
          • count
            • integer
            • The number of individual approvals (i.e. approvals by different people) required for an event to be approved.
            • Default: 1
          • self_approval
            • boolean
            • Whether or not the requestor for this approval request can approve their own action.
            • Default: false
          • duration
            • integer, representing minutes
            • After an event in this workflow is approved, auto-approve subsequent events with the same id.
            • Default: 0
            • Experimental
          • timeout
            • integer, representing minutes
            • How long an approval request is valid before it will timeout.
            • Default: 10
          • responders
            • object of objects
            • What groups or user can respond (i.e. approve) this action. Any number of key/value pairs can be given.
            • Each key in the object should be either:
              • A group name representing a group, e.g., admins
              • A group id representing a group, e.g., group_1s8bso0Mr80MHli6fBb9QfZ5POr
              • An email address associated with a Cased user, e.g., [email protected]
              • A user ID representing a user, e.g. user_1s8bsqKiRoTxWe8hQmsq2LFF74Q
            • Each value should be strings of either:
              • required indicating that this group/user must approve the request.
              • optional indicating that this group/user can approve the request.
          • sources
            • object
            • Represents the mechanisms that can be used to approve requests.
            • Valid keys are strings, and include:
              • email
                • Set the value to true to enable email approval.
              • slack
                • The value for this is an object of form:
                1
                {
                2
                "channel": "#your-channel-name",
                3
                "fields": ["ip", "command", "reason"]
                4
                }
                Copied!
              • Object keys:
                • fields (Optional)
                  • The metadata you would like to see in a slack approval request notification.
                  • If not supplied, all metadata will show in the message.
          • oncalls
            • object
            • Represents the mechanisms that can be used to auto-approve requests when requester is oncall.
            • Valid keys are strings, and include:
              • pagerduty
                • Set the value to your pagerduty escalation policy name.
  • conditions Optional
    • An array of structured conditions that determine whether or not this workflow is activated.
    • Each array object should be of form:
      1
      {
      2
      "field": "service",
      3
      "value": "my-service-name",
      4
      "operator": "eq"
      5
      }
      Copied!
    • In this example, if an event is sent to the /workflows/events route with field called service, and the value of that field is my-service-name, then this workflow will be executed.
    • Valid operators include:
      • eq for equivalence (not case-sensitive)
      • not for non-equivalence (not case-sensitive)
      • Future fields with include regular expression matchers.
Last modified 1mo ago
Copy link