Crumbs REST API Use Cases

Table of contents

You can use the Crumbs REST API to read and modify customer information. This page provides some common use cases of using Jira Automation.

Copy customer fields to an issue

Scenario:

  1. In Crumbs, create a customer and add information into a field.

  2. In Jira Automation, setup an automation to read the linked customer, lookup the customer and copy customer values to an issue.

  3. In Jira, link a customer to an issue.

Jira Automation Steps

Step

Component

Details

Step

Component

Details

1

When: Field value changed

 

The trigger can be actioned anytime you wish to copy the customer details over to the issue. Note that customers are linked after issue creation (which means that it must be triggered on issue update.

Fields to monitor for changes: Customer

Change type: Any changes to the field value

For: Edit issue

2

Then: Send web request

 

Use the Crumbs API to find the customerId of the customer linked.

Web request: https://crumbs.newverve.scot/api/1/issueLink/{{issue.key}}

Headers:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

3

And: Send web request

 

Use the Crumbs API to get the customer details.

Web request: https://crumbs.newverve.scot/api/1/customer/{{webResponse.body.customerIds.first}}

Headers:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

4

And: Edit issue fields

 

Change an issue field to something based on the data from the Crumbs customer linked.

Choose fields to copy customer to e.g.

Request participant: {{webResponse.body.fields.mainContact}}

If you are copying a custom field, you will need to know the fieldId. You can find this with GET /field. e.g. if the fieldId is 0a647c60-2513-40c2-a61a-2683cf19c1dd, to access the field use the following smart value:

{{webResponse.body.fields.0a647c60-2513-40c2-a61a-2683cf19c1dd}}.

Email main contact when customer is linked

Scenario:

  1. In Crumbs, create a customer with a main contact.

  2. In Jira Automation, setup an automation to read the linked customer, lookup a customer and email the main contact.

  3. In Jira, create an issue and link the customer.

Jira Automation Steps

Step

Component

Details

Step

Component

Details

1

When: Field value changed

 

Detect a field value change to trigger this automation.

Fields to monitor for changes: Customer

Change type: Any changes to the field value

For: Edit issue

2

Then: Send web request

Use the Crumbs API to find the customerId of the customer linked.

Web request: https://crumbs.newverve.scot/api/1/issueLink/{{issue.key}}

Header:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

3

And: Send web request

Use the Crumbs API to get the customer details.

Web request: https://crumbs.newverve.scot/api/1/customer/{{webResponse.body.customerIds.first}}

Header:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

4

And: Send web request

 

Use the Jira API to convert the user accountId to an email address. See Get user for more information.

Web request: https://<site>.atlassian.net/rest/api/3/user?accountId={{webResponse.body.fields.mainContact}}

Header:

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

5

And: Send email

 

Now we can send the email out.

To: {{webResponse.body.emailAddress}}

Fill in the desired email details.

Link a customer automatically when an issue is created

Scenario:

  1. In Crumbs, create a customer.

  2. In Jira Automation, setup an automation to link a customer.

  3. In Jira, create an issue.

Jira Automation Steps

Step

Component

Details

Step

Component

Details

1

When: Issue is created

 

Use the issue created trigger to run this automation when any issue is created.

2

Then: Send web request

 

Use the Crumbs API to link a customer to the issue.

Web request: https://crumbs.newverve.scot/api/1/issueLink/{{issue.key}}

Header:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: POST

Web request body: Custom Data

Custom data:

{ "customerId": "<customerId>" }

Use GET /customer to get the customerId.

Modify customer based on issue information

In this scenario, we want to track the total budget used by requests from the customer.

Scenario:

  1. In Crumbs, create a customer and a line field for ‘Budget Used’.

  2. In Jira administration, create a ‘Cost’ number field and add it to the screen.

  3. In Jira Automation, setup the automation to increment the budget by the issue cost.

  4. In Jira, populate the cost field for an issue and link a customer to the issue and trigger the automation, for example by transitioning the issue.

Jira Automation Steps

Step

Component

Details

Step

Component

Details

1

When: Issue is transitioned

 

Example trigger when an issue is marked done to add the cost of the issue to the budget used.

From status: In Progress

To status: Done

2

Then: Send web request

 

Use the Crumbs API to find the customerId of the customer linked.

Web request: https://crumbs.newverve.scot/api/1/issueLink/{{issue.key}}

Header:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

3

And: Create variable

 

Save the smart value customerId to be used in later steps.

Variable name: customerId

Smart value: {{webResponse.body.customerIds.first}}

4

And: Send web request

 

Use the Crumbs API to get the customer details.

Web request: https://crumbs.newverve.scot/api/1/customer/{{customerId}}

Header:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: GET

Web request body: Empty

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request

5

And: Create variable

 

Calculate the total and save it to a variable. This step is optional but makes it easier to explain.

Variable name: total

Smart value: {{#=}}{{issue.fields.<Cost issue field ID>|0}} + {{webResponse.body.fields.<Budget customer field ID>.asNumber|0}}{{/}}

The smart value is broken down into:

  • {{#=}} - The start of a maths expression.

  • {{issue.fields.<Cost custom field ID>|0}} - The Cost issue field value.

    • Replace <Cost custom field ID> with the ID of the custom field e.g. customfield_10001. This can be found using the GET /field Jira API.

    • |0 - will default the value to 0.

  • + Here we are adding the cost of the issue to the existing budget used.

  • {{webResponse.body.fields.<Budget customer field ID>.asNumber|0}} - The Budget Used customer field value.

    • Replace <Budget customer field ID> with the ID of the custom field e.g. cc659e96-cb91-4e81-a8fa-cdf222c2dcef. This can be found using the GET /field Crumbs API.

    • |0 - will default the value to 0.

  • {{/}} - The end of the maths expression.

6

And: Send web request

 

Use the Crumbs API to modify the customer details.

Web request: https://crumbs.newverve.scot/api/1/customer/{{customerId}}

Header:

  • Name: Authorization

  • Value: Bearer <Crumbs API token>

HTTP method: PUT

Web request body: Custom data

Custom data:

{ "<Budget customer field ID>": {{total}} }
  • Replace <Budget customer field ID> with the ID of the custom field e.g. cc659e96-cb91-4e81-a8fa-cdf222c2dcef. This can be found using the GET /field Crumbs API.

Wait for response:

  • Delay execution of subsequent rule actions until we've received a response for this web request