Data Segregation Tutorial
Any operations here behave as if you executed them from our own server.
Section 1 - Creating Multiple Teams in XQ
Teams within XQ are self-contained entities, each managing its own keys, users, policies, and communication logs.
Use the following steps to create a team in XQ:
- Navigate to the XQ Dashboard and authenticate using magic-link, Google, or Microsoft.
- In the top-right corner click on Personal Dashboard followed by selecting + Create a new team.
- Input your team name (Team A) followed by click on Next to proceed.
- Invite members to your team by entering their email addresses in the text field and clicking Next. You can also choose Skip for now to add team members later.
- Once your team is created select your name/email address on the top right-hand side of the screen followed by Account & Billing in the dropdown.
- The Team ID is in the "Organization" section, this will be required for Section 2.
Repeat steps 2 - 6 and create another team with a different name (Team B) ensuring to note down the Team ID for each.
Section 2 - Authorizing and Storing an Encryption Key Packet in Team A
To interact with XQ servers and leverage the XQ APIs/SDKs, you'll need General and/or Dashboard API keys. Follow these steps to obtain them:
You can utilize either team to create your API keys just be aware your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, etc.
- Open the XQ Dashboard.
- Authenticate using magic link, Google, or Microsoft authentication.
- Navigate to Applications via the navigation bar on the left-hand side.
Creating API Keys
To generate API keys for the first time, refer to the following steps:
- Enter a name in the Name your application field. Optionally, add a description if needed.
- Click CREATE APPLICATION.
- In the Name of key field, provide a name for your API key.
- From the API dropdown, select either General or Dashboard.
- Optional - Specify a space-delimited list of IP addresses allowed to use this key in the IP Access Restrictions field.
- Click CONTINUE.
- Save your API key in a safe place. Your API key is only visible once.
The Dashboard API key is utilized for the Manage API functionality, while the General API key is utilized for Quantum, Subscription, and Validation API functionalities.
If you need access to multiple features, generate multiple API keys with the corresponding dropdown group in Step 4.
(Optional) Listing a User's Team IDs
You can list a users team(s) and their IDs by having them authenticate then making a request to the dashboard businesses endpoint.
First you can send a magic link to a users email address using the following endpoint.
Parameters — /login/link
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | Dashboard API key |
email | string | Yes | The email address of the user. |
state | string | Optional parameter that would pass through from the frontend and get placed as query parameter in the magic link that is in the email. This can be used for the front end to determine which flow the user is coming from, and therefore which screen the user should be sent to after they have successfully logged in. | |
host | string | The host domain that login links will target. If not provided, the server instance default will be used. |
A successful response will return a 204 status code, indicating that the email has been successfully sent to the specified user. The email will include a one-time-use access_token embedded in a URI, which will be used in the next step. You can copy the link from the email and extract the access_token from the URI. Please note in a standard implementation you would handle this utilizing the state request payload.
The access_token then needs to be exchanged for a valid authentication token.
Parameters — /login/verify
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | Dashboard API key |
authorization | string | Yes | This is a bearer token required to make most XQ API calls. To get one, a user must first utilize the login/link endpoint, upon which they get a pre-auth token. |
A successful response will return a 200 with a new access token which can be used to get user specific information.
Finally, you can use the business dashboard endpoint to retrieve a list of all the user's teams along with their respective IDs.
Parameters — /businesses
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | Dashboard API key |
authorization | string | Yes | This is a bearer token required to make most XQ API calls. |
A successful response will return an object containing all of the users teams and their respective Id's
Authorizing a User Using a Specific Team
An authorized user is identified by an email address that is granted an authorization token (authToken). This token is used to store and access the protected key.
During the /exchange step, set the "Team A" team ID as b
Parameters — /authorize
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
user | string | Yes | The email address or phone number of the account to validate. The confirmation link or code will be sent to this address or number |
A successful response includes the Pre-Auth Token that will allow the subscriber to exchange it in conjunction with the 2FA pin received in their email/phone with an authToken. Store the Pre-Auth Token for use in following step of the tutorial.
Parameters — /codevalidation
| Name | Type | Required | Description |
|---|---|---|---|
token | string | Yes | The Pre-Auth token that is returned after an initial request for authorization. |
pin | integer | Yes | The pin that was sent to the users email or phone number. |
A successful response will return a 204 with "No Content" but this will validate your pre-auth token with your 2fa credentials.
Parameters — /exchange
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
Authorization | string | This is a bearer token required to make most XQ API calls. To get one, a user must first utilize the authorize endpoint, upon which they get a pre-auth token. After they confirm their account utilizing the code-validation endpoint, they can then exchange the pre-auth token in return for an access token to a specific team. | |
b | integer | This is the specific Team ID you are using to exchange your pre-auth token for authorization. If no Team ID is specified, you will automatically be authorized into the Team ID with the lowest index that you have access to. |
A successful response will return a 200 with a new access token which can be used to store and access protected keys in that specific team.
Creating and saving the key packet to XQ
This step involves taking the user's secret key that needs protection and the recipient which will be "Active Team", then automatically generating and storing an encrypted key packet in the XQ keystore.
Parameters — /packet/add
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
authorization | string | Yes | authToken returned in /exchange response. Prefix the auth token with "Bearer" |
recipients | string | Yes | Comma-delimited list of email addresses or phone numbers who are allowed to access the key. |
expires | integer | Yes | Number of hours that this key will remain valid for. After this time, it will no longer be accessible. |
key | string | Yes | The secret key that the user wants to protect. |
type | string | A value indicating the type of data that is being encrypted. Values are 1 = “file”, 2 = “msg”, 3 = “chat”, 4 = “form”, 5 = “data” | |
meta | object | Any additional meta information about the key. |
A successful response means your key packet is now stored on the key server. The response contains the locator token used to retrieve your encryption key in the future.
Fetching your decryption key authorized to team A
Before you can decrypt a message, you must retrieve the key that was used for encryption. Use the locator token that XQ provides when the key is uploaded. The locator token was the return value in the previous step.
Parameters — /key/{locatorToken}
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
authorization | string | Yes | authToken returned in /exchange response. Prefix the auth token with "Bearer" |
locatorToken | string | This token is the response received when storing the key packet on the server. Make sure to URI encode the locatorToken |
Section 3 - Authorizing and Attempting Access to a Key from Team B
We will repeat the authorization and key retrieval process outlined above, but this time, we will exchange the pre-auth token for a different team ID.
During the /exchange step, set the "Team B" team ID as b
Parameters — /authorize
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
user | string | Yes | The email address or phone number of the account to validate. The confirmation link or code will be sent to this address or number |
A successful response includes the Pre-Auth Token that will allow the subscriber to exchange it in conjunction with the 2FA pin received in their email/phone with an authToken. Store the Pre-Auth Token for use in following step of the tutorial.
Parameters — /codevalidation
| Name | Type | Required | Description |
|---|---|---|---|
token | string | Yes | The Pre-Auth token that is returned after an initial request for authorization. |
pin | integer | Yes | The pin that was sent to the users email or phone number. |
A successful response will return a 204 with "No Content" but this will validate your pre-auth token with your 2fa credentials.
Parameters — /exchange
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
Authorization | string | This is a bearer token required to make most XQ API calls. To get one, a user must first utilize the authorize endpoint, upon which they get a pre-auth token. After they confirm their account utilizing the code-validation endpoint, they can then exchange the pre-auth token in return for an access token to a specific team. | |
b | integer | This is the specific Team ID you are using to exchange your pre-auth token for authorization. If no Team ID is specified, you will automatically be authorized into the Team ID with the lowest index that you have access to. |
A successful response will return a 200 with a new access token which can be used to store and access protected keys in that specific team.
Fetching your decryption key authorized to team A
Use the locator token that XQ provides when the key is uploaded. The locator token was the return value in the previous section.
Parameters — /key/{locatorToken}
| Name | Type | Required | Description |
|---|---|---|---|
api-key | string | Yes | General API key |
authorization | string | Yes | authToken returned in /exchange response. Prefix the auth token with "Bearer" |
locatorToken | string | This token is the response received when storing the key packet on the server. Make sure to URI encode the locatorToken |