Tutorial: Create Stream
This tutorial will show you how to create a Stream Group and a Stream
Requirements
Create Stream Group and Stream
Stream Groups logically organize one or more Streams. We need to create a Stream Group first.
- Portal
- API
Select the Workspace in the upper right corner of the page.
Open the link Data Flows in the left sidebar.
You'll see the list of Streams that are organized into Stream Groups. Click the Create new Stream Group button.
Fill in the name of the Stream Group and click the Save button to create the Stream Group.
Click the new Stream Group in the list of Streams. Click the Create new Strea button.
Fill in the name of the new Stream. Set Batch ID Autofill Pattern to
{dateTime:yyyy-MM-dd}
and Message ID Autofill Pattern to{dateTime:yyyy-MM-dd}_{sequenceId}
. Click Save to create the Stream.Select the new Stream from the list of Streams to see the details of the Stream.
The following instructions expect that you have already obtained the API access token from the Portal and that you know the ID of the Workspace you want to use. If you don't know the Workspace ID, you can find it in the Portal under the link Workspaces in the left sidebar.
Create Stream Group
Replace the placeholders <Your Workspace ID>
, <Your Stream Group Name>
and <Your API Access Token>
with your Workspace ID, your Stream Group name and API access token and run the following command to create a new Stream Group:
- cURL
- PowerShell
curl -X PATCH 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/<Your Stream Group Name>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"properties": {"storage": {"useWorkspaceStorage": true}}}'
(Invoke-WebRequest -Method Patch -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/<Your Stream Group Name>' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"properties": { "storage": { "useWorkspaceStorage": true }}}').Content
The API will confirm the creation and display the Stream Group details:
{
"name": "my-new-stream-group",
"workspaceId": "fd0123eb-159d-4613-925d-4167d7413d6b",
"version": 1,
"ingressVersion": "V2",
"properties": {
"storage": {
"isWorkspaceStorage": true
},
"defaultStream": {
"isEnabled": false
}
}
}
Create Stream
Replace the placeholders <Your Workspace ID>
, <Your Stream Group Name>
, <Your Stream Name>
and <Your API Access Token>
with your Workspace ID, your Stream Group name, your Stream name and API access token and run the following command to create a new Stream in the Stream Group:
- cURL
- PowerShell
curl -X PATCH 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/<Your Stream Group Name>/streams/<Your Stream Name>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"properties": {"batchIdAutoFillPattern": {"isEnabled": true, "pattern": "{dateTime:yyyy-MM-dd}"}, "messageIdAutofillPattern": {"isEnabled": true, "pattern": "{dateTime:yyyy-MM-dd}_{sequenceId}"}, "concatenationMode": "None"}}'
(Invoke-WebRequest -Method Patch -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/<Your Stream Group Name>/streams/<Your Stream Name>' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{ "properties": { "batchIdAutoFillPattern": { "isEnabled": true, "pattern": "{dateTime:yyyy-MM-dd}" }, "messageIdAutofillPattern": { "isEnabled": true, "pattern": "{dateTime:yyyy-MM-dd}_{sequenceId}" }, "concatenationMode": "None" }}').Content
The API will confirm the creation and display the Stream Group details:
{
"name": "my-new-stream",
"streamGroupName": "my-new-stream-group",
"workspaceId": "fd0123eb-159d-4613-925d-4167d7413d6b",
"version": 1,
"properties": {
"concatenationMode": "None",
"batchCompletionTimeout": {
"isEnabled": false
},
"batchIdAutoFillPattern": {
"isEnabled": true,
"pattern": "{dateTime:yyyy-MM-dd}"
},
"messageIdAutoFillPattern": {
"isEnabled": true,
"pattern": "{dateTime:yyyy-MM-dd}_{sequenceId}"
}
}
}
What's Next
- The following tutorial shows how to send data from a Device to a Stream.
- The parent page Send Data from Devices explains Messages, Streams and other related concepts in more detail.