# Introduction

To complement our API, Rightsline offers three ways to receive message notifications on events.  An AWS Simple Queue Service ("SQS") FIFO queue, the use of AWS Simple Notification Service ("SNS") Topics, or AWS EventBridge event bus.  More information on SQS can be found [here](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html), SNS [here](/sns/overview), and EventBridge [here](/eventbridge/setting-up-an-eventbridge-integration).


# Getting started

### Considerations

A few things to consider and get organized if you are ready to start receiving messages from Rightsline:

* A Rightsline SQS queue or EventBridge event bus will be populated with every audit event that occurs, so this is best suited for customers who need integrations to a wide variety of data points.
* SNS messages are much more targeted as the topics are based on a specific char types in Rightsline (e.g. Catalog Item, Deal, etc.) and can further be filtered in the subscription by specific actions (created, updated, deleted), individual user performing the action, template or status of the entity, as well as other [message attributes](/sns/message-attributes).
* We have updated our security policies in accordance with AWS best practices and require all customers that need to subscribe to SQS or SNS messages to have their own AWS account. You will need to provide us with that account ID in order to set up the correct permissions for all of the resources involved.

### Setting up a new messaging integration

First, determine what type of message destination works best for your use case:

* If you are interested in every type of event across multiple char types, or do not have an AWS account, jump to [Setting up SQS message integration](/sqs/setting-up-an-sqs-message-integration).
* If you are only interested in select events or events from a few char types and have an AWS account, jump to [Setting up SNS message integration](/sns/setting-up-an-sns-message-integration).&#x20;
* If you have an AWS account and would like to route your messages to multiple AWS services in your account, jump to [Connect your event bus to Rightsline event bus](/eventbridge/setting-up-an-eventbridge-integration).


# Transitioning from v2 to v4

A guide for transitioning from using v2 of our message queuing to v4.

## Coordinated Launch of API and Messaging Updates

In coordination with the messaging updates, we are launching v4 of our API. Since the changes to the object structures in our messages are consistent with the changes made to response objects on the API side, we opted to skip a version 3 release of the messaging infrastructure and instead keep the version numbers in lock step between the features.&#x20;

## Customer-owned subscriptions

Rightsline messaging v4 enables customers to manage their own subscriptions to our SNS topics.  You will need to provide us with your AWS account ID as well as the char types that you would like to receive messages for (e.g. Deals, Catalog Items, etc.), and we will provide your personalized SNS topic ARNs.  Using your AWS account, you can create subscriptions to these topics to trigger custom logic using AWS Lambda, populate a queue using AWS SQS, or call an external HTTP endpoint for some downstream system.

### Creating an SNS subscription

1. In order to create a subscription to your SNS topics, access the [AWS SNS Dashboard](https://console.aws.amazon.com/sns).
2. Select *Subscriptions*, and click **Create Subscription**.
3. Under *Topic ARN,* input the provided SNS topic ARN.  Select the protocol where you would like the message delivered.
4. Under *Subscription filter policy*, add any filters that you would like to your subscription.  You can filter on any message attribute value.  See [Message Attributes](/sns/message-attributes).

![](https://1230650179-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MGAeYsGmflcmJcE_7Ap%2F-MS9iMz8ZlMMaIoXRj4I%2F-MSEAjuC-v9421bAHQ3m%2Fsub_filter_policy.PNG?alt=media\&token=b82a7bfa-4fbf-4cdc-895f-308d596ef902)

### Assume AWS role to interact with SNS topic

Rightsline will provide an [AWS IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) ARN that you will need to assume in order to interact with the messages on the SNS topic. Using this role, you will be able to retrieve credentials that will give you access to receive messages from your SNS topics.  For more information, see [Switching to an IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-api.html).

## New Message Attributes

We have added additional message attributes to all of our messages to allow more precise filtering of messages.  For all message attributes, see [here](/sns/message-attributes).

## New Message Structure

We have redesigned the structure of our messages to provide more information about the event.  For complete examples, see [here](/sqs/overview).  Some of the specific changes are:

* Removed `entityUrl`, `rootEntityUrl`, `parentUrl`, `childUrl` properties. These properties have been replaced with entity objects, with the names `entity`, `rootEntity`, `parentEntity`, `childEntity`. The `entityId`, `charTypeId`, `template`, and `status` have all been moved inside the entity object.  The workflow `processId` and `processName` have been added to the template object.

#### **v2**

```javascript
{
    "entityId": 3300,
    "entityUrl": "https://api.rightsline.com/v2/catalog-item/3300"
}
```

#### v4

```javascript
{
    "entity" : {
        "entityId": 3300, 
        "charTypeId": 1, 
        "status": {
            "statusId": 1, 
            "statusName": "Development"
        }, 
        "template": {
            "templateId": 1, 
            "templateName":"Series",
            "processId": 4,
            "processName": "Catalog Workflow"
        }
    }
}
```

* `statusUpdatedById`, `statusUpdatedDate` have been added to all entity messages.

```javascript
{
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

* `relationshipType` object has been added to relationship messages.

```javascript
{
    "relationshipType": {
        "relationshipTypeId": 0,
        "relationshipTypeName": "Default"
    }
}
```

## Workflow actions published to relevant char type topic

We have removed the `action-executed` SNS topics. Workflow action event messages will now be sent to the relevant char type SNS topic, with an `action` value of `action-executed`. For instance, if a workflow action is taken on a deal, you will receive a message to the deal (`ct4`) SNS topic.  An example action-executed message can be found [here](/message-structure/entity-messages/examples#action-executed).


# Message structure

Messages are sent as a JSON string.  The fields in the JSON object vary depending on the type of message, but they always include:

* [messageGroupId](/message-structure/entity-messages/message-group)
* [action](/message-structure/entity-messages/action)
* audit information (createdBy, createdDate, lastUpdatedBy, lastUpdatedDate, etc.)

### Entity Messages

Entity messages, no matter the char type or action, will contain an entity field with details of the entity that the action was performed on. For instance:

```
"entity": {
    "entityId": 3830,
    "charTypeId": 1,
    "template": {
        "templateId": 1,
        "templateName": "Feature"
    },
    "status": {
        "statusId": 1,
        "statusName": "Development"
    }
}
```

#### Component Entity Messages

Component entity messages are entity messages that are performed specifically on component records. The component char types can be identified in [this table](/message-structure/entity-messages/message-group). A component char type is a record that cannot exist on it's own. It must exist as a child of another record. Therefore, there is an additional field on component entity messages called `rootEntity`.  The root entity is the parent of the component record, and contains the parents char type ID and record ID:

```
"rootEntity": {
    "entityId": 3830,
    "charTypeId": 1
}
```

### Relationship Messages

Relationship messages will have fields for both the `parentEntity` and `childEntity` such as:

```
"parentEntity": {
    "entityId": 3830,
    "charTypeId": 1,
    "template": {
        "templateId": 1,
        "templateName": "Feature"
    },
    "status": {
        "statusId": 1,
        "statusName": "Development"
    }
},
"childEntity": {
    "entityId": 2978,
    "charTypeId": 3,
    "template": {
        "templateId": 1,
        "templateName": "Rights In"
    },
    "status": {
        "statusId": 1,
        "statusName": "Active"
    }
}
```

Examples of each of the messages can be found [here](/message-structure/entity-messages/examples).


# Entity messages


# Message group

Each message published by Rightsline will have a `messageGroupId` that will be populated with the Char Type identifier of the entity the message is referencing.

| Message Group ID | Char Type    | API Endpoint        | Module/Component |
| ---------------- | ------------ | ------------------- | ---------------- |
| 0                | Relationship | /relationship       | N/A              |
| 1                | Catalog Item | /catalog-item       | Module           |
| 2                | Contact      | /contact            | Module           |
| 3                | Right        | /right              | Component        |
| 4                | Deal         | /deal               | Module           |
| 5                | Table        | /table              | Component        |
| 7                | Accounting   | /financial-document | Module           |
| 10               | Amount       | /amount             | Component        |
| 14               | File         | /file               | Component        |
| 15               | Job          | /job                | Module           |
| 16               | Project      | /project            | Module           |
| 17               | Inventory    | /inventory          | Module           |


# Action

The following actions are supported and will send out a message:

* created
* updated
* deleted
* action-executed
* availability-changed


# Example messages

Examples of messages that will be published.

For Right, Table, Amount, and File char types, an additional message property will be included in the messages to ensure the proper context within Rightsline is provided, called `rootEntity`.

### Catalog Item Created

```javascript
{
    "action": "created",
    "messageGroupId": 1,
    "entity": {
        "entityId": 3830,
        "charTypeId": 1,
        "template": {
            "templateId": 1,
            "templateName": "Feature"
        },
        "status": {
            "statusId": 0,
            "statusName": null
        }
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T19:58:46.777Z",
    "lastUpdatedById": 12345,
    "lastUpdatedDate": "2019-02-21T19:58:46.777Z",
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

### Catalog Item Updated

```javascript
{
    "action": "updated",
    "messageGroupId": 1,
    "entity": {
        "entityId": 3830,
        "charTypeId": 1,
        "template": {
            "templateId": 1,
            "templateName": "Feature"
        },
        "status": {
            "statusId": 1,
            "statusName": "Development"
        }
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T19:58:46.777Z",
    "lastUpdatedById": 12345,
    "lastUpdatedDate": "2019-02-21T19:58:48.373Z",
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

### Catalog Item Deleted

```javascript
{
    "action": "deleted",
    "messageGroupId": 1,
    "entity": {
        "entityId": 3830,
        "charTypeId": 1,
        "template": {
            "templateId": 1,
            "templateName": "Feature"
        },
        "status": {
            "statusId": 1,
            "statusName": "Development"
        }
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T19:58:46.777Z",
    "deletedById": 12345,
    "deletedDate": "2019-02-21T20:21:48.2105751Z",
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

### Right Created

```javascript
{
    "action": "created",
    "messageGroupId": 3,
    "entity": {
        "entityId": 2978,
        "charTypeId": 3,
        "template": {
            "templateId": 1,
            "templateName": "Rights In"
        },
        "status": {
            "statusId": 0,
            "statusName": null
        }
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T20:00:39.18Z",
    "lastUpdatedById": 12345,
    "lastUpdatedDate": "2019-02-21T20:00:39.18Z",
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

### Right Updated

```javascript
{
    "rootEntity": {
        "entityId": 3830,
        "charTypeId": 1
    },
    "action": "updated",
    "messageGroupId": 3,
    "entity": {
        "entityId": 2978,
        "charTypeId": 3,
        "template": {
            "templateId": 1,
            "templateName": "Rights In"
        },
        "status": {
            "statusId": 1,
            "statusName": "Active"
        }
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T19:58:46.777Z",
    "lastUpdatedById": 12345,
    "lastUpdatedDate": "2019-02-21T20:00:44.72Z",
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

### Right Deleted

```javascript
{
    "rootEntity": {
        "entityId": 3830,
        "charTypeId": 1
    },
    "action": "deleted",
    "messageGroupId": 3,
    "entity": {
        "entityId": 2978,
        "charTypeId": 3,
        "template": {
            "templateId": 1,
            "templateName": "Rights In"
        },
        "status": {
            "statusId": 1,
            "statusName": "Active"
        }
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T20:01:50.8377191Z",
    "deletedById": 12345,
    "deletedDate": "2019-02-21T20:01:50.8377191Z",
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
}
```

### Relationship Created

```javascript
{
    "action": "created",
    "messageGroupId": 0,
    "entityId": 214562,
    "parentEntity": {
        "entityId": 3830,
        "charTypeId": 1,
        "template": {
            "templateId": 1,
            "templateName": "Feature"
        },
        "status": {
            "statusId": 1,
            "statusName": "Development"
        }
    },
    "childEntity": {
        "entityId": 2978,
        "charTypeId": 3,
        "template": {
            "templateId": 1,
            "templateName": "Rights In"
        },
        "status": {
            "statusId": 1,
            "statusName": "Active"
        }
    },
    "relationshipType": {
        "relationshipTypeId": 0,
        "relationshipTypeName": "Default"
    },
    "createdById": 12345,
    "createdDate": "2019-02-21T19:58:46.777Z"
}
```

### Action Executed

This message is to track the event of a Workflow Action being taken; with or without a status change. The `action` of the message will be `action-executed`, and the message will contain new fields to hold the data on what action was taken, who took the action, and when.

```javascript
{
    "action": "action-executed",
    "messageGroupId": 4,
    "entity": {
        "entityId": 609,
        "charTypeId": 4,
        "template": {
            "templateId": 2,
            "templateName": "Distribution Deal"
        },
        "status": {
            "statusId": 24,
            "statusName": "Approval Requested"
        }
    },
    "createdById": 12345,
    "createdDate": "2019-04-24T19:01:41.653Z",
    "lastUpdatedById": 12345,
    "lastUpdatedDate": "2019-04-25T18:03:56.147Z",,
    "statusUpdatedById": 12345,
    "statusUpdatedDate": "2019-02-21T19:58:46.777Z"
    "actionExecutedById": 12345,
    "actionExecutedDate": "2019-04-30T17:54:29.5152074Z" ,
    "executedActionId": 27
}
```

### Availability Changed

This message will have the same `messageGroupId` as the Right char type, and the `action` will be `availability-changed`.

The dimension keys will show the current state of the dimensions at the time of the message.

```javascript
{
    "id": "42411544-61e8-41c6-affd-cc1da8d0d6f7",
    "rootEntities": [
        {
            "entityId": 3,
            "charTypeId": 1
        },
        {
            "entityId": 1048,
            "charTypeId": 1
        },
        {
            "entityId": 23,
            "charTypeId": 4
        }
    ],
    "action": "availability-changed",
    "messageGroupId": 3,
    "entity": {
        "entityId": 37,
        "charTypeId": 3,
        "template": {
            "templateId": 1,
            "templateName": "Rights In"
        },
        "status": {
            "statusId": 1,
                "statusName": "Active"
        },
    },
    "windowStart": "2016-04-01T00:00:00Z",
    "windowEnd": "2025-04-30T00:00:00Z",
    "isExclusive": true,
    "activeIndicatorChanged": false,
    "dim1": [
        {
            "id": 2,
            "xref": null,
            "value": "All Media"
        }
    ],
    "dim1Added": [],
    "dim1Removed": [],
    "dim2": [
        {
            "id": 1,
            "xref": null,
            "value": "Worldwide"
        }
    ],
    "dim2Added": [],
    "dim2Removed": [],
    "dim3": [
        {
            "id": 4,
            "xref": null,
            "value": "All Languages"
        }
    ],
    "dim3Added": [],
    "dim3Removed": [],
    "dim4": [],
    "dim4Added": [],
    "dim4Removed": [],
    "createdById": 12345,
    "createdDate": "2016-04-22T03:30:23.12Z"
}
```


# Configuration messages


# Message group

Each message published by Rightsline will have a `messageGroupId` that will be populated with one of the following values.

| Message Group ID | Char Type                                          |
| ---------------- | -------------------------------------------------- |
| 102              | Picklist, Picklist Source, Picklist Preset Changes |


# Action

The following actions are supported and will send out a message:

#### Picklist Sources

* picklist-source-created
* picklist-source-updated
* picklist-source-deleted

#### Picklist Source Values

* picklist-source-value-created
* picklist-source-value-updated
* picklist-source-value-deleted

#### Picklists

* picklist-created
* picklist-updated
* picklist-deleted

#### Picklist Values

* picklist-value-added
* picklist-hierarchy-updated
* picklist-value-removed

#### Picklist Presets

* picklist-preset-created
* picklist-preset-updated
* picklist-preset-deleted

#### Picklist Preset Values

* picklist-preset-value-added
* picklist-preset-value-removed


# Example messages

Examples of messages that will be published.

## Picklist Sources

### Picklist Source Created

```javascript
{
    "action": "picklist-source-created",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:39:41.543Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:39:41.543Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:39:41.543Z",
    "messageGroupId": 102,
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    }
}
```

### Picklist Source Updated

```json
{
    "action": "picklist-source-updated",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:39:41.543Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:39:41.543Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:46:08.417Z",
    "messageGroupId": 102,
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    }
}
```

### Picklist Source Deleted

```javascript
{
    "action": "picklist-source-deleted",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:39:41.543Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:39:41.543Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:46:08.417Z",
    "deletedById": 12345,
    "deletedDate": "2025-02-21T20:21:48.2105751Z",
    "messageGroupId": 102,
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    }
}
```

## Picklist Source Values

### Picklist Source Value Created

```javascript
{
    "action": "picklist-source-value-created",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:47:19.68Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:47:19.68Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:47:19.68Z",
    "messageGroupId": 102,
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    },
    "picklistValue": {
        "description": "Picklist Source Value Description",
        "id": 4,
        "value": "Picklist Source Value"
    }
}
```

### Picklist Source Value Updated

```javascript
{
    "action": "picklist-source-value-updated",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:47:19.68Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:47:19.68Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:47:19.68Z",
    "messageGroupId": 102,
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    },
    "picklistValue": {
        "description": "Picklist Source Value Description",
        "id": 4,
        "value": "Picklist Source Value"
    }
}
```

### Picklist Source Value Deleted

```javascript
{
    "action": "picklist-source-value-created",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:47:19.68Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:47:19.68Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:47:19.68Z",
    "deletedById": 12345,
    "deletedDate": "2025-02-21T20:21:48.2105751Z",
    "messageGroupId": 102,
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    },
    "picklistValue": {
        "description": "Picklist Source Value Description",
        "id": 4,
        "value": "Picklist Source Value"
    }
}
```

## Picklists

### Picklist Created

```javascript
{
    "action": "picklist-created",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:42:06.683Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:42:06.683Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:42:06.683Z",
    "messageGroupId": 102,
    "picklist": {
        "description": "Picklist Description",
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    }
}
```

### Picklist Updated

```javascript
{
    "action": "picklist-updated",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:42:06.683Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:42:06.683Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:42:06.683Z",
    "messageGroupId": 102,
    "picklist": {
        "description": "Picklist Description",
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    }
}
```

### Picklist Deleted

```javascript
{
    "action": "picklist-deleted",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:42:06.683Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:42:06.683Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:42:06.683Z",
    "deletedById": 12345,
    "deletedDate": "2025-02-21T20:21:48.2105751Z",
    "messageGroupId": 102,
    "picklist": {
        "description": "Picklist Description",
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    }
}
```

## Picklist Values

### Picklist Value Added

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>    "action": "picklist-value-added",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:40:29.79Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:40:29.79Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:40:29.747Z",
    "messageGroupId": 102,
    "picklist": {
        "description": "Picklist Description",
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    },
    "picklistValue": {
        "id": 2
    }
}
</code></pre>

### Picklist Hierarchy Updated

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>    "action": "picklist-hierarchy-updated",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:40:29.79Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:40:29.79Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:40:29.747Z",
    "messageGroupId": 102,
    "picklist": {
        "description": "Picklist Description",
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    },
    "picklistValue": {
        "id": 2
    }
}
</code></pre>

### Picklist Value Removed

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>    "action": "picklist-value-removed",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:40:29.79Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:40:29.79Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:40:29.747Z",
    "messageGroupId": 102,
    "picklist": {
        "description": "Picklist Description",
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistSource": {
        "description": "Picklist Source Description",
        "id": "f70f55e1-56e5-ee11-8351-065151be1e5f",
        "name": "Picklist Source Name"
    },
    "picklistValue": {
        "id": 2
    }
}
</code></pre>

## Picklist Presets

### Picklist Preset Created

<pre class="language-javascript"><code class="lang-javascript"><strong>{
</strong>    "action": "picklist-preset-created",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:42:06.683Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:42:06.683Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:42:06.683Z",
    "messageGroupId": 102,
    "picklist": {
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistPreset": {
        "description": "Picklist Preset Description",
        "id": "50e02513-1e07-ef11-8352-065151be1e5f",
        "name": "Picklist Preset Name"
    }
}
</code></pre>

### Picklist Preset Updated

```javascript
{
    "action": "picklist-preset-updated",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:42:06.683Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:42:06.683Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:42:06.683Z",
    "messageGroupId": 102,
    "picklist": {
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistPreset": {
        "description": "Picklist Preset Description",
        "id": "50e02513-1e07-ef11-8352-065151be1e5f",
        "name": "Picklist Preset Name"
    }
}
```

### Picklist Preset Deleted

```javascript
{
    "action": "picklist-preset-deleted",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-03-18T18:42:06.683Z",
    "createdById": 1094364,
    "createdDate": "2024-03-18T18:42:06.683Z",
    "deletedById": 1094364,
    "deletedDate": "2024-03-18T18:42:06.683Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-03-18T18:42:06.683Z",
    "messageGroupId": 102,
    "picklist": {
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistPreset": {
        "description": "Picklist Preset Description",
        "id": "50e02513-1e07-ef11-8352-065151be1e5f",
        "name": "Picklist Preset Name"
    }
}
```

## Picklist Preset Values

### Picklist Preset Value Added

```javascript
{
    "action": "picklist-preset-value-added",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-04-30T22:16:26.72Z",
    "createdById": 1094364,
    "createdDate": "2024-04-30T18:18:43.547Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-04-30T18:18:43.547Z",
    "messageGroupId": 102,
    "picklist": {
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistPreset": {
        "description": "Picklist Preset Description",
        "id": "50e02513-1e07-ef11-8352-065151be1e5f",
        "name": "Picklist Preset Name"
    }
    "picklistValue": {
        "id": 9,
        "value": "Picklist Value"
    }
}
```

### Picklist Preset Value Removed

```javascript
{
    "action": "picklist-preset-value-removed",
    "actionExecutedById": 1094364,
    "actionExecutedDate": "2024-04-30T22:19:10.96Z",
    "createdById": 1094364,
    "createdDate": "2024-04-30T18:18:43.547Z",
    "lastUpdatedById": 1094364,
    "lastUpdatedDate": "2024-04-30T18:18:43.547Z",
    "deletedById": 1094364,
    "deletedDate": "2024-04-30T18:18:43.547Z",
    "messageGroupId": 102,
    "picklist": {
        "id": "7f99d737-57e5-ee11-8351-065151be1e5f",
        "name": "Picklist Name"
    },
    "picklistPreset": {
        "description": "Picklist Preset Description",
        "id": "50e02513-1e07-ef11-8352-065151be1e5f",
        "name": "Picklist Preset Name"
    }
    "picklistValue": {
        "id": 9,
        "value": "Picklist Value"
    }
}
```


# Financial messages


# Message group

Each message published by Rightsline will have a messageGroupId that will be populated with one of the following values.

| Message Group ID | Char Type             |
| ---------------- | --------------------- |
| 100              | Currency Pair Changes |


# Action

The following actions are supported and will send out a message:

#### Currency Pair

* currency-pair-created
* currency-pair-updated
* currency-pair-deleted


# Example messages

Examples of messages that will be published.

## Currency Pairs

### Currency Pair Created

```
{
    "conversionId": 4972,
    "currencyConversionId": "00000000-0000-0000-0000-000000000000",
    "toCurrency": "USD",
    "fromCurrency": "AUD",
    "rate": 1.110000000,
    "effectiveDate": "2023-04-04T00:00:00Z",
    "conversionType": {
        "conversionTypeId": 0,
        "conversionTypeName": "Transaction To Company"
    },
    "rateSource": {
        "rateSourceId": 5,
        "rateSourceName": "Default"
    },
    "isLocked": false,
    "createdById": 124523,
    "createdDate": "2023-04-17T21:06:05.357Z",
    "lastUpdatedById": 124523,
    "lastUpdatedDate": "2023-04-17T21:06:05.357Z"
}
```

### Currency Pair Updated

```
{
    "conversionId": 4972,
    "currencyConversionId": "00000000-0000-0000-0000-000000000000",
    "toCurrency": "USD",
    "fromCurrency": "AUD",
    "rate": 1.112000000,
    "effectiveDate": "2023-04-04T00:00:00Z",
    "conversionType": {
        "conversionTypeId": 0,
        "conversionTypeName": "Transaction To Company"
    },
    "rateSource": {
        "rateSourceId": 5,
        "rateSourceName": "Default"
    },
    "isLocked": false,
    "createdById": 124523,
    "createdDate": "2023-04-17T21:06:05.357Z",
    "lastUpdatedById": 124523,
    "lastUpdatedDate": "2023-04-18T16:41:38.413Z"
}
```

### Currency Pair Deleted

```
{
 "conversionId": 4972,
    "currencyConversionId": "00000000-0000-0000-0000-000000000000",
    "toCurrency": "USD",
    "fromCurrency": "AUD",
    "rate": 1.112000000,
    "effectiveDate": "2023-04-04T00:00:00Z",
    "conversionType": {
        "conversionTypeId": 0,
        "conversionTypeName": "Transaction To Company"
    },
    "rateSource": {
        "rateSourceId": 5,
        "rateSourceName": "Default"
    },
    "isLocked": false,
    "createdById": 124523,
    "createdDate": "2023-04-17T21:06:05.357Z",
    "lastUpdatedById": 124523,
    "lastUpdatedDate": "2023-04-18T16:41:38.413Z",
    "deletedById": 124523,
    "deletedDate": "2023-04-18T16:44:57.307Z"
}
```


# Batch Messages


# Message group

Each message published by Rightsline will have a messageGroupId that will be populated with one of the following values.

| Message Group ID | Char Type      |
| ---------------- | -------------- |
| 104              | Batch Messages |


# Action

The following actions are supported and will send out a message:

#### Currency Pair

* batch-created
* batch-inprogress
* batch-complete
* batch-error
* batch-cancelled


# Example messages

Examples of messages that will be published.

## Batch Messages

### Batch Update

```json
{
    "id": 10293192384,
    "status": "Complete",
    "lastUpdatedById": 124523,
    "lastUpdatedDate": "2023-04-17T21:06:05.357Z"
}
```

### Batch Create

```json
{
    "id": 10293192384,
    "status": "Complete",
    "lastUpdatedById": 450293,
    "lastUpdatedDate": "2023-04-17T21:06:05.357Z",
    "createdById": 450293,
    "createdDate": "2023-04-17T21:06:05.357Z",
}
```


# Sample projects

Updated sample projects will be provided as needed. Once publicly available, they will be found with our API sample projects for .NET, Java and Python on our GitHub [here](https://github.com/rightsline/sample-projects)


# Message metrics

Some high level metrics are available to monitor messaging throughput.

In the UI, metrics can be found by going to **Admin** > **Integrations**. Under the **Audit Messaging** tab, you'll be able to see the current number of queued messages, the number of messages sent over a given timeframe, and the current message delay between when the action was taken and when the message was sent.

Further, each of these metrics can be queried from the API using the following calls:

## Gets counts of audit events yet to have messages sent out

<mark style="color:blue;">`GET`</mark> `https://ris.rightsline.com/v4/messages-queued`

This endpoint will return count of audit events (grouped by the entity type - charTypeId) that are queued up to be sent out as messages. &#x20;

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| x-api-key<mark style="color:red;">\*</mark>     | String | Your company's API key. |
| Authorization<mark style="color:red;">\*</mark> | String | Authentication token    |

{% tabs %}
{% tab title="200: OK Success return of queued message counts" %}

```json
{
    "queuedMessagesByCharType": [
        {
            "charTypeId": 0,
            "count": 9999
        },
        {
            "charTypeId": 1,
            "count": 8888
        },
        {
            "charTypeId": 3,
            "count": 7777
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Get the number of messages sent over a time period

<mark style="color:green;">`POST`</mark> `https://ris.rightsline.com/v4/messages-sent`

Specify a startDate and endDate that must be within the past month. Response will be a count of the messages that were sent out during that time frame.

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| x-api-key<mark style="color:red;">\*</mark>     | String | Your company's API key. |
| Authorization<mark style="color:red;">\*</mark> | String | Authentication token    |

#### Request Body

| Name      | Type     | Description                                                                                 |
| --------- | -------- | ------------------------------------------------------------------------------------------- |
| startDate | DateTime | Start of the time frame to query messages sent. Must be within past 30 days.                |
| endDate   | DateTime | End of the time frame to query messages sent. Must be less than 30 days from the startDate. |

{% tabs %}
{% tab title="200: OK Total count of messages sent during time frame" %}
9999
{% endtab %}
{% endtabs %}

## Get an average delay (in seconds) for the messages sent during the time frame

<mark style="color:green;">`POST`</mark> `https://ris.rightsline.com/v4/message-delay`

Specify a startDate and endDate that must be within the past month. Response will be the average time between when an event occurred to when the message(s) for that event were sent out.&#x20;

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| x-api-key<mark style="color:red;">\*</mark>     | String | Your company's API key. |
| Authorization<mark style="color:red;">\*</mark> | String | Authentication token    |

#### Request Body

| Name      | Type     | Description                                                                                                                                                       |
| --------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| startDate | DateTime | Start of the time frame to query messages sent. Must be within past 30 days. Expected in ISO format and UTC time zone (e.g. "2023-09-09T12:00:00")                |
| endDate   | DateTime | End of the time frame to query messages sent. Must be less than 30 days from the startDate. Expected in ISO format and UTC time zone (e.g. "2023-09-09T12:00:00") |

{% tabs %}
{% tab title="200: OK Average message delay in seconds, rounded to the nearest tenth." %}
1234.5
{% endtab %}
{% endtabs %}


# FAQ

Answers to some of our frequently asked questions about messaging.

#### I did not receive a message that I was expecting, what should I do?

First, ensure you have allowed some time for the message to be sent after the action was taken. If after 15-30 minutes you still have not received the message, check to see if your [messages are delayed](#how-can-i-check-if-my-messages-are-delayed). Also check that you have no other system that is set up to read/delete messages from your message destination that may be intercepting the message. Finally, confirm that the audit event and corresponding message data exists via the UI Audit History or the API audit history details endpoint. If all else fails, contact Rightsline support with the record ID, the action taken, an estimated timestamp of the action, and the user that took the action for investigation.

#### How can I check if my messages are delayed?

Messages can become delayed when a large volume of messages are generated over a short timeframe. A user with Super Admin permissions can access information regarding message delays via the UI by going to **Admin** > **Integrations**. Under the **Audit Messaging** tab, you'll be able to see the current number of queued messages, the number of messages sent over a given timeframe, and the current message delay between when the action was taken and when the message was sent.

#### How can I check how many messages are queued?

A user with Super Admin permissions can access information regarding the number of messages queued via the UI by going to **Admin** > **Integrations**. Under the **Audit Messaging** tab, you'll be able to see the current number of queued messages, the number of messages sent over a given timeframe, and the current message delay between when the action was taken and when the message was sent.  The number of queued messages on this screen represents the number of Rightsline events that are queued to be sent to an Amazon EventBridge, an SQS queue, or an SNS topic, not the current number of messages on a given queue.

#### If a relationship is deleted, will I receive messages for both the parent and child records?

No. Any time a relationship between a parent and child is removed, it is deemed an update to the parent only. For example if an episode is removed from a season, it is considered an update to the season. If you need a message that includes the child record, you should be listening for the relationship delete message.

#### I am not receiving action-executed messages when a bulk create records. Is this expected?

Yes. When a single record is created, you will receive both a `created` message and an `action-executed` message. When creating records in bulk, you will only receive `created` messages for each of the records. This is because we do not take the initial workflow action on records when they are created in bulk, they are simply put into their intial workflow status.


# Overview

These queues are best when there is only one consumer.  All char types and actions are represented on the FIFO queue.  Acknowledgement of the message is necessary in order to take the message off the queue.  If no acknowledgement is received, the message is placed back onto the queue.

Our queues adhere to the following:

1. Each queue is set to the SQS FIFO queue defaults: visibility timeout is 30 seconds, and maximum message retention period is 4 days.
2. Since these are FIFO queues, maximum inflight messages per queue is 20,000.  If that limit is hit, you won’t receive any overlimit errors (unlike Standard queues).
3. There is no dead letter or redrive policy set up on these queues; which means you can receive messages as many times without deleting them.


# Setting up an SQS message integration

Below are the steps to set up a new AWS SQS message integration with Rightsline:

1. If you do not already have an AWS Account, you will need to [create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
2. Contact [Rightsline Support](https://support.rightsline.com) to request an SQS queue with your AWS Account ID number and the Rightsline environment(s) where you would like messages.
3. Rightsline will provide the AWS `SQS queue ARN(s)`, the `IAM role ARN(s)` you will need to assume in order to access the queue, and the `external ID(s)` you will use to assume those roles.
4. To configure an AWS profile for your new IAM role, you can use AWS CLI and run the following commands.  Remember to replace `<ROLE_ARN>`, `<EXTERNAL_ID>`, and `<REGION>` with the values provided in step 3.

   <pre data-full-width="false"><code>aws configure --profile rl-sqs-profile set role_arn &#x3C;ROLE_ARN>
   aws configure --profile rl-sqs-profile set external_id &#x3C;EXTERNAL_ID>
   aws configure --profile rl-sqs-profile set role_session_name rl-sqs-session
   aws configure --profile rl-sqs-profile set source_profile default
   aws configure --profile rl-sqs-profile set region &#x3C;REGION>
   </code></pre>
5. To test your SQS access, run the following command.  Replace `<QUEUE_NAME>` with the queue name provided in step 3.

   ```
   aws sqs get-queue-url --queue-name <QUEUE_NAME> --queue-owner-aws-account-id 013474081760 --profile rl-sqs-profile
   ```
6. If you receive a successful response, you are all set to start receiving messages from your SQS queue.  If you receive a permissions error, reach out to Rightsline Support.

### Receiving messages from the SQS queue using .NET SDK

```aspnet
public static async Task ReceiveSqsMessages()
{
	var roleArnToAssume = "<ROLE_ARN>";
	var externalId = "<EXTERNAL_ID>";
	var queueName = "<QUEUE_NAME>";
	RegionEndpoint region = RegionEndpoint.USWest2;

	var client = new Amazon.SecurityToken.AmazonSecurityTokenServiceClient(region);

	// Create the request to use with the AssumeRoleAsync call.
	var assumeRoleRequest = new AssumeRoleRequest()
	{
		RoleSessionName = "rl-sqs-session",
		RoleArn = roleArnToAssume,
		ExternalId = externalId
	};

	var assumeRoleResponse = await client.AssumeRoleAsync(assumeRoleRequest);

	// Now create a new client based on the credentials of the caller assuming the role.
	var sqsClient = new Amazon.SQS.AmazonSQSClient(credentials: assumeRoleResponse.Credentials);

	var queueUrlResponse = await sqsClient.GetQueueUrlAsync(new GetQueueUrlRequest
	{
		QueueName = queueName,
		QueueOwnerAWSAccountId = "013474081760"
	});

	// Receive the messages from the SQS queue.
	var receiveMessageResponse = await sqsClient.ReceiveMessageAsync(new ReceiveMessageRequest
	{
		QueueUrl = queueUrlResponse.QueueUrl,
		MaxNumberOfMessages = 10,
		WaitTimeSeconds = 10
	});

	var messages = receiveMessageResponse.Messages;
}
```

For examples of how to assume the IAM role with other programming languages, see the AWS documentation [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/example_sts_AssumeRole_section.html).


# SQS queue names

The SQS queue names are unique per client, RL environment, and version.  SQS queue names have the following structure:

`{environment}-rtl-div{client_id}-{version}.fifo`

For instance, `prd-rtl-div1-v4.fifo` topic would receive messages for Production environment, client ID 1, and version 4.


# Overview

Rightsline utilizes Amazon Simple Notification Service for our pub/sub messaging system.

Messages are published to SNS topics by the Char Type of the entity.  Subscribers to these topics are able to filter what types of messages they receive using a [Subscription Filter Policy](https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html).

For example, if a subscriber is only interested in messages for entities that are created or updated and are of a specific template, they could use the following Subscription Filter Policy:

```javascript
{
  "action": [
    "created",
    "updated"
  ],
   "templateID": [
    {
      "numeric": [
        "=",
        3
      ]
    }
  ]
}
```

Messages can be filtered by any of the included [Message Attributes](/sns/message-attributes).

If we will be maintaining your subscriptions, contact Rightsline Support with the following to get started:

1. Desired environment(s) – Integration, Staging, Production
2. Endpoint - HTTPS endpoint, or SQS Standard queue ARN
3. Needed Entities and actions, i.e. Catalog Item, Create and Update

Permissions will be needed in order for subscriptions to be properly created.  Rightsline will inform you on how to setup the permissions for the chosen endpoint once supplied. Once we set up the subscription, you will need to check your endpoint for a confirmation message as well as a confirmation URL and confirm your subscription.

If you will be maintaining your own subscription (new to v4!), in addition to the environment(s) and char types you are interested in, we will only need the AWS account ID you will be using to create the subscriptions in order to update the security policies on our side.


# Setting up an SNS message integration

Below are the steps to set up a new AWS SNS message integration with Rightsline:

1. Determine the [actions](/message-structure/entity-messages/action) and [char types](/message-structure/entity-messages/message-group) of the messages in which you are interested.
2. Create an SQS queue in your AWS account. The queue can be either Standard or FIFO.
3. Modify the access policy for the SQS queue to allow the Rightsline AWS account to publish messages to the queue.  The Rightsline AWS account ID `013474081760` should be granted the `sqs:SendMessage` permission like the following, replacing `{{YOUR_QUEUE_ARN}}` with the ARN of your queue, and `{{REGION}}` with the AWS Region the SNS topic is hosted in, found [here](/sns/topic-names#aws-regions):&#x20;

   ```
   {
     "Statement": [{
       "Effect":"Allow",
       "Principal": {
         "Service": "sns.amazonaws.com"
       },
       "Action":"sqs:SendMessage",
       "Resource":"{YOUR_QUEUE_ARN}",
       "Condition":{
         "ArnEquals":{
           "aws:SourceArn":"arn:aws:sns:{{REGION}}:013474081760:*"
         }
       }
     }]
   }
   ```
4. Ensure the message retention period on the SQS queue is set to at least 4 days to ensure that subscription confirmation messages are not automatically deleted.  More information can be found [here](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-basic-architecture.html).
5. Contact [Rightsline Support](https://support.rightsline.com) with the **actions and the char types** (from Step 1), your **AWS Account ID** number, and the **Rightsline environment(s)** that you would like messages for so that we can create the necessary SNS topics and IAM role(s) with the proper permissions.
6. Rightsline will create the SNS topics and IAM role(s) that will be provided to you (per environment).  Topics will have the following format: `{environment}-rtl-div{client_id}-{version}-ct{char_type_id}` See [SNS topic names](/sns/topic-names) for more details.
7. To configure an AWS profile for your new IAM role, you can use AWS CLI and run the following commands. Remember to replace `<ROLE_ARN>`, `<EXTERNAL_ID>`, and `<REGION>` with the values provided in step 6.

   <pre data-full-width="false"><code>aws configure --profile rl-sns-profile set role_arn &#x3C;ROLE_ARN>
   aws configure --profile rl-sns-profile set external_id &#x3C;EXTERNAL_ID>
   aws configure --profile rl-sns-profile set role_session_name rl-sns-session
   aws configure --profile rl-sns-profile set source_profile default
   aws configure --profile rl-sns-profile set region &#x3C;REGION>
   </code></pre>
8. You should then be able to subscribe to the provided SNS topics. Replace the `<TOPIC_ARN>` with the value provided in step 6 and `<QUEUE_ARN>` with the ARN of your SQS queue.

   <pre data-full-width="false"><code>aws sns subscribe ––topic-arn &#x3C;TOPIC_ARN> ––protocol sqs ––notification-endpoint &#x3C;QUEUE_ARN> --profile rl-sns-profile
   </code></pre>
9. If the subscription is successful, you will receive a Pending Subscription message. &#x20;
10. Poll the SQS queue for messages.  If messages are found of the queue, open the contents of the message and locate the `SubscribeURL`.  Copy the URL to a web browser and click enter.  You should receive a message that the subscription is now confirmed, and you will start to receive messages to your SQS queue.


# SNS topic names

The SNS topic names are unique per client, RL environment, version, and char type.  SNS topic names have the following structure:

`{environment}-rtl-div{client_id}-{version}-ct{char_type_id}`

For instance, `prd-rtl-div1-v4-ct3` topic would receive messages for Production environment, client ID 1, version 4, and char type 3 (rights).

We publish to both Standard and FIFO topics for each of the above, so `prd-rtl-div1-v4-ct3.fifo` is also available.

### SNS Topic ARNs

The ARN (Amazon Resource Name) is a unique identifier for a resource within AWS.  The Rightsline  SNS topic ARNs have the following format:

`arn:aws:sns:{region}:013474081760:{topic_name}`

The topic name is determined in the previous section.  The region varies based on the Rightsline environment you are receiving messages from.  See the table below:

### AWS Regions

| RL Environment                                                      | AWS region   |
| ------------------------------------------------------------------- | ------------ |
| Prod Mirror                                                         | us-east-1    |
| All EU environments                                                 | eu-central-1 |
| All other environments (including Staging, Integration, Production) | us-west-2    |


# Message attributes

Key-value pairs that allow messages to be filtered to specific subscribers.

Each SNS message contains a collection of key-value pairs called **message attributes**. The attributes of a particular message depend on the action that is performed on the entity.  Message attributes are used to filter messages to an SNS topic's subscribers, to ensure a subscriber only receives the events in which they are interested. Below are the message attributes included for the following types of messages:

* [Entity - Create, Update, Delete](/sns/message-attributes#entity-create-update-delete)
* [Entity - Action Executed](/sns/message-attributes#entity-action-executed)
* [Entity - Availability Changed](/sns/message-attributes#entity-availability-changed)
* [Relationship - Create, Update, Delete](/sns/message-attributes#relationship-create-update-delete)

## Entity - Create, Update, Delete

| Attribute Name | Data Type | Description                                            |
| -------------- | --------- | ------------------------------------------------------ |
| action         | string    | *created, updated, deleted*                            |
| charTypeID     | number    | The char type ID of the entity.                        |
| templateID     | number    | The template ID of the entity.                         |
| statusID       | number    | The status ID of the entity.                           |
| userID         | number    | The ID of the user that took the action on the entity. |

## Entity - Action Executed

| Attribute Name   | Data Type | Description                                            |
| ---------------- | --------- | ------------------------------------------------------ |
| action           | string    | *action-executed*                                      |
| charTypeID       | number    | The char type ID of the entity.                        |
| templateID       | number    | The template ID of the entity.                         |
| statusID         | number    | The status ID of the entity.                           |
| userID           | number    | The ID of the user that took the action on the entity. |
| executedActionID | number    | The ID of the action executed.                         |
| processID        | number    | The ID of the workflow process for the entity.         |

## Entity - Availability Changed

| Attribute Name | Data Type | Description                                            |
| -------------- | --------- | ------------------------------------------------------ |
| action         | string    | *availability-changed*                                 |
| charTypeID     | number    | The char type ID of the entity.                        |
| templateID     | number    | The template ID of the entity.                         |
| statusID       | number    | The status ID of the entity.                           |
| userID         | number    | The ID of the user that took the action on the entity. |

## Relationship - Create, Update, Delete

| Attribute Name     |        | Description                                                  |
| ------------------ | ------ | ------------------------------------------------------------ |
| action             | string | *created, updated, deleted*                                  |
| charTypeID         | number | *0*                                                          |
| relationshipTypeID | number | The type ID of the relationship.                             |
| parentCharTypeID   | number | The char type ID of the parent entity.                       |
| childCharTypeID    | number | The char type ID of the child entity.                        |
| parentTemplateID   | number | The template ID of the parent entity.                        |
| childTemplateID    | number | The template ID of the child entity.                         |
| parentStatusID     | number | The status ID of the parent entity.                          |
| childStatusID      | number | The status ID of the child entity.                           |
| userID             | number | The ID of the user that took the action on the relationship. |


# Overview

Rightsline is now integrated as an Amazon EventBridge partner.  This means you can now get started receiving messages from Rightsline directly to your AWS Account.

To get started, follow the steps [here](/eventbridge/setting-up-an-eventbridge-integration).


# Setting up an EventBridge integration

### 1. **Create a Standard AWS SQS queue**

1. Log in to the [AWS Console](https://console.aws.amazon.com/).
2. Open `Amazon SQS` from the Services dropdown or the Services search bar at the top of the page.
3. Click `Create queue`.
4. Select **Standard** queue type.
5. Give your SQS queue a name, and click `Create queue`.
6. Make note of the ARN of the newly created queue.

### **2. Contact your Rightsline representative**

1. Provide them with your *AWS Account ID* and the *AWS region* that you would like to set up your EventBridge integration.
2. Your Rightsline representative will provide you with your AWS EventBridge **event source name**.  You will use this name to create your AWS EventBridge event bus.

### 3. Create an AWS EventBridge event bus (AWS CLI)

Because the event bus name has to start with `aws.partner/rightsline.com/` it cannot be created in the UI.  You must create your AWS EventBridge event bus via the AWS CLI.  To do so, run the following commands:

```
aws events create-event-bus --name aws.partner/rightsline.com/{{EVENT_SOURCE_NAME}} --event-source-name aws.partner/rightsline.com/{{EVENT_SOURCE_NAME}} --region {{REGION}}
```

At this point the remainder of the setup can continue to be done via the CLI or you can scroll down to see how it can be set up in the Console.

In the above command, replace `{{EVENT_SOURCE_NAME}}` with the event source name provided by Rightsline in the [second section](#contact-your-rightsline-representative) above.  Replace `{{REGION}}` with the desired region provided to Rightsline in the [second section](#contact-your-rightsline-representative) above.

```
aws events put-rule --cli-input-json file://rule.json --region {{REGION}}
```

In the above command, replace `{{REGION}}` with the desired region provided to Rightsline in the [second section](#contact-your-rightsline-representative) above.  The file://rule.json file must exist in the directory you are running the command.  The file should look like the following:

{% code title="rule.json" %}

```json
{
    "Description": "Rule Description",
    "EventBusName": "aws.partner/rightsline.com/{{EVENT_SOURCE_NAME}}",
    "EventPattern": "{\"source\": [{\"prefix\": \"aws.partner/rightsline.com/{{EVENT_SOURCE_NAME}}\"}]}",
    "Name": "RuleName",
    "State": "ENABLED"
}
```

{% endcode %}

In the above command, replace `{{EVENT_SOURCE_NAME}}` with the event source name provided by Rightsline in the [second section](#contact-your-rightsline-representative) above.

```
aws events put-targets --cli-input-json file://targets.json --region {{REGION}}
```

In the above command, replace `{{REGION}}` with the desired region provided to Rightsline in the [second section](#contact-your-rightsline-representative) above.  The `file://targets.json` file must exist in the directory you are running the command.  The file should look like the following:

{% code title="targets.json" %}

```json
{
    "Rule": "RuleName",
    "EventBusName": "aws.partner/rightsline.com/{{EVENT_SOURCE_NAME}}",
    "Targets": [{
            "Id": "1",
            "Arn": "{{SQS_QUEUE_ARN}}"
        }
    ]
}
```

{% endcode %}

In the above command, replace `{{EVENT_SOURCE_NAME}}` with the event source name provided by Rightsline in the [second section](#contact-your-rightsline-representative) above.  Replace `{{SQS_QUEUE_ARN}}` with the SQS queue ARN from the [first section](#create-an-aws-sqs-queue) above.

**Create an AWS EventBridge Rule (Console)**

Once the steps above have been completed to create the event bus via the CLI, the Rule setup can happen in the console as follows:

1. Open `Rules` in the left sidebar menu.
2. Select your new Event bus from the dropdown, and click `Create rule`.
3. Give your rule a name, and make sure ***Rule with an event pattern*** is selected. Click `Next`.
4. Under Event source, select ***AWS events or EventBridge partner events***.

<figure><img src="https://1230650179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGAeYsGmflcmJcE_7Ap-3778137224%2Fuploads%2FhqeFakZ3UP9eESLrpXNt%2Fevb_source.JPG?alt=media&amp;token=45f23963-1b94-4946-bcbd-bfaff2ae6d65" alt=""><figcaption><p>Rightsline event source</p></figcaption></figure>

10. Under Event pattern, select ***EventBridge*** ***partners***, and select ***Rightsline*** as the partner.  For Event type, select ***All Events.***  Click `Next`***.***

<figure><img src="https://1230650179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGAeYsGmflcmJcE_7Ap-3778137224%2Fuploads%2FiW85rzYVI2bSfdeA2jRt%2Fevb_pattern.JPG?alt=media&amp;token=bf7ab428-27f3-4627-a659-98cbb6348282" alt=""><figcaption><p>Rightsline event pattern</p></figcaption></figure>

11. Under Target 1, select ***AWS service***, ***SQS queue***, and the queue name created from the [first section](#create-an-aws-sqs-queue). Click `Next`.
12. Add any relevant Tags. Click `Next`.
13. Click `Create Rule`.

### 4. Granting access for your SQS queue to receive messages from the Event Bus Rule

Once the SQS queue, the Event Bus, and the Event Bus Rule are created, you need to modify the access policy on the SQS queue to allow it to receive messages from your new Event Bus Rule.  Navigate to your new SQS queue in the AWS Console, click on **Access Policy**, then **Edit**.  Your access policy will need to include the following Statement:

```json
{
  "Sid": "sampleStatment",
  "Effect": "Allow",
  "Principal": {
    "Service": "events.amazonaws.com"
  },
  "Action": "sqs:SendMessage",
  "Resource": "{{SQS_QUEUE_ARN}}",
  "Condition": {
    "ArnEquals": {
      "aws:SourceArn": "{{EVENT_BUS_RULE_ARN}}"
    }
  }
}
```

In the above Statement, replace `{{SQS_QUEUE_ARN}}` with the ARN of the SQS queue, and `{{EVENT_BUS_RULE_ARN}}` with the ARN of the Event Bus Rule.  This should grant your new Event Bus Rule to forward messages to your SQS queue.&#x20;


