> This page is for Developers.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.iot.telia.lt/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.iot.telia.lt/_mcp/server.

# Create data stream

POST https://iot.telia.lt/api/v2/data_stream
Content-Type: application/json

Create Data Stream to your destination.
Click on Examples to see available Data Streams and configuration parameters.

Currently available `connection_types` are
- `AwsKinesis`
- `S3`
- `RestAPI`
- `KeenIO`
- `Datadog`
- `EventHubs`
- `PubSub`


Reference: https://docs.iot.telia.lt/developers/api/integrations/create-data-streamer

## Authentication

- `Authorization` header (bearer token, required) — An `auth_token` should be provided to authenticate a session. To obtain an `auth_token`, see the [`/api/v1/authenticate` **POST** request](/developers/api/authentication/authenticate).

## Request

### Body (application/json)

This endpoint expects an object.

- `name` (string, optional) — Descriptive name or purpose of the data stream
- `destination` (ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestination, optional)
- `filters` (list of ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaFiltersItems, optional)
- `data_stream_type` (any, optional)
- `relation_resolution` (any, optional)
- `status` (any, optional)

## Response

### 201

Data stream has been successfully created.

## Errors

### 401 Unauthorized Error

No or invalid authentication token provided

- `any`

### 403 Forbidden Error

Authentication token is valid, but user has no access permissions to the request resource

- `any`

### 404 Not Found Error

A non-existent resource is requested

- `any`

### 422 Unprocessable Entity Error

Configuration for the data stream is invalid. Please check your Request Body for errors.

- `error_code` (integer, required)
- `error_token` (string, required)
- `message` (string, required)

## Types

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestination

- `connection_type` (string, required)
- `format` (string, optional)
- `credentials` (ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials, optional) — Destination credentials

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaFiltersItems

- `field` (string, optional) — Field to filter on
- `value` (list of string, optional) — Values to filter on

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials

Destination credentials

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials0

Credential fields for Amazon Kinesis Data Streams

- `region` (string, required) — AWS Region of your Kinesis Data Stream
- `stream_name` (string, required) — Name of your Kinesis Data Stream
- `role_arn` (string, required) — Role ARN of IAM role with write permission for your Kinesis Stream

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials1

Credential fields for Amazon S3

- `region` (string, required) — AWS Region of your Kinesis Data Stream
- `bucket_name` (string, required) — Name of your S3 bucket
- `role_arn` (string, required) — Role ARN of IAM role with write permission for your S3 bucket
- `flush_size` (integer, optional) — Maximal number of entries in a single file. Default is `10000`. Valid flush sizes are between 10 and 100000.
- `rotate_interval` (integer, optional) — Maximal time in milliseconds between file writes. Default is `10000` ms. Valid rotation intervals are between 10000 ms and 900000 ms.

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials2

Credential fields for Webhook

- `url` (string, required) — URL of your Webhook / RestAPI endpoint
- `method` (string, optional) — HTTP Method to use. Options are `POST` (default), `PUT` and `PATCH`
- `headers` (list of string, optional) — Array containing additional header tuples. Expected Format is `["header1:value1, "header2:value2", ...]`. Headers are masked in GET request.
- `size` (integer, optional) — Number specifying of request should contain `1` message or an array of messages of the specified batch size. Default is `3000`. Valid sizes are between 1 and 10000.

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials3

Credential fields for KeenIO

- `project_id` (string, required) — Project ID reported by KeenIO
- `write_key` (string, required) — Write key of your KeenIO Project.
- `collection_name` (string, required) — Collection Name that you want to stream your data to.
- `size` (integer, optional) — Number specifying of request should contain `1` message or an array of messages of the specified batch size. Default is `3000`. Valid sizes are between 1 and 10000.

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials4

Credential fields for Datadog

- `api_key` (string, required) — Datadog API Key
- `region` (string, optional) — Datadog region. Options are `US` (default), `US3`, `EU` and `US1FED`

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials5

Credential fields for Microsoft Azure EventHub

- `connection_string` (string, required) — Connection string with Access Key to your Event Hub.

### ApiV2DataStreamPostRequestBodyContentApplicationJsonSchemaDestinationCredentials6

Credential fields for Google Cloud Pub/Sub

- `cps_topic` (string, required) — Topic name of PubSub topic
- `cps_project` (string, required) — Project ID of the topic project.

## Examples

### Amazon Kinesis Data Streams - Usage Data

**Request**

```json
{
  "name": "Production Kinesis stream",
  "destination": {
    "connection_type": "AwsKinesis",
    "format": "Json",
    "credentials": {
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
      "stream_name": "demo-stream"
    }
  },
  "data_stream_type": {
    "id": 1
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Amazon Kinesis Data Streams - Usage Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "Production Kinesis stream",
    "destination": {
        "connection_type": "AwsKinesis",
        "format": "Json",
        "credentials": {
            "region": "af-south-1",
            "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
            "stream_name": "demo-stream"
        }
    },
    "data_stream_type": { "id": 1 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Amazon Kinesis Data Streams - Usage Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Production Kinesis stream","destination":{"connection_type":"AwsKinesis","format":"Json","credentials":{"region":"af-south-1","role_arn":"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream","stream_name":"demo-stream"}},"data_stream_type":{"id":1}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Amazon Kinesis Data Streams - Usage Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"Production Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Amazon Kinesis Data Streams - Usage Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Production Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Amazon Kinesis Data Streams - Usage Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Production Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php Amazon Kinesis Data Streams - Usage Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "Production Kinesis stream",
  "destination": {
    "connection_type": "AwsKinesis",
    "format": "Json",
    "credentials": {
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
      "stream_name": "demo-stream"
    }
  },
  "data_stream_type": {
    "id": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Amazon Kinesis Data Streams - Usage Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Production Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Amazon Kinesis Data Streams - Usage Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Production Kinesis stream",
  "destination": [
    "connection_type": "AwsKinesis",
    "format": "Json",
    "credentials": [
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
      "stream_name": "demo-stream"
    ]
  ],
  "data_stream_type": ["id": 1]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Amazon Kinesis Data Streams - Event Data with Filters

**Request**

```json
{
  "name": "Filtered Kinesis stream",
  "destination": {
    "connection_type": "AwsKinesis",
    "format": "Json",
    "credentials": {
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
      "stream_name": "demo-stream"
    }
  },
  "filters": [
    {
      "field": "event_type_id",
      "value": [
        "1",
        "2",
        "3"
      ]
    }
  ],
  "data_stream_type": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Amazon Kinesis Data Streams - Event Data with Filters
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "Filtered Kinesis stream",
    "destination": {
        "connection_type": "AwsKinesis",
        "format": "Json",
        "credentials": {
            "region": "af-south-1",
            "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
            "stream_name": "demo-stream"
        }
    },
    "filters": [
        {
            "field": "event_type_id",
            "value": ["1", "2", "3"]
        }
    ],
    "data_stream_type": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Amazon Kinesis Data Streams - Event Data with Filters
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Filtered Kinesis stream","destination":{"connection_type":"AwsKinesis","format":"Json","credentials":{"region":"af-south-1","role_arn":"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream","stream_name":"demo-stream"}},"filters":[{"field":"event_type_id","value":["1","2","3"]}],"data_stream_type":{"id":2}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Amazon Kinesis Data Streams - Event Data with Filters
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"Filtered Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"event_type_id\",\n      \"value\": [\n        \"1\",\n        \"2\",\n        \"3\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Amazon Kinesis Data Streams - Event Data with Filters
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Filtered Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"event_type_id\",\n      \"value\": [\n        \"1\",\n        \"2\",\n        \"3\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Amazon Kinesis Data Streams - Event Data with Filters
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Filtered Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"event_type_id\",\n      \"value\": [\n        \"1\",\n        \"2\",\n        \"3\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Amazon Kinesis Data Streams - Event Data with Filters
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "Filtered Kinesis stream",
  "destination": {
    "connection_type": "AwsKinesis",
    "format": "Json",
    "credentials": {
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
      "stream_name": "demo-stream"
    }
  },
  "filters": [
    {
      "field": "event_type_id",
      "value": [
        "1",
        "2",
        "3"
      ]
    }
  ],
  "data_stream_type": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Amazon Kinesis Data Streams - Event Data with Filters
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Filtered Kinesis stream\",\n  \"destination\": {\n    \"connection_type\": \"AwsKinesis\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_kinesis_data_stream\",\n      \"stream_name\": \"demo-stream\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"event_type_id\",\n      \"value\": [\n        \"1\",\n        \"2\",\n        \"3\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Amazon Kinesis Data Streams - Event Data with Filters
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Filtered Kinesis stream",
  "destination": [
    "connection_type": "AwsKinesis",
    "format": "Json",
    "credentials": [
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_kinesis_data_stream",
      "stream_name": "demo-stream"
    ]
  ],
  "filters": [
    [
      "field": "event_type_id",
      "value": ["1", "2", "3"]
    ]
  ],
  "data_stream_type": ["id": 2]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Webhook - Event Data

**Request**

```json
{
  "name": "My Webhook Stream",
  "destination": {
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": {
      "headers": [
        "header1:value1",
        "header2:value2"
      ],
      "method": "POST",
      "size": 3000,
      "url": "https://example.com"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Webhook - Event Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My Webhook Stream",
    "destination": {
        "connection_type": "RestAPI",
        "format": "Json",
        "credentials": {
            "headers": ["header1:value1", "header2:value2"],
            "method": "POST",
            "size": 3000,
            "url": "https://example.com"
        }
    },
    "data_stream_type": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Webhook - Event Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My Webhook Stream","destination":{"connection_type":"RestAPI","format":"Json","credentials":{"headers":["header1:value1","header2:value2"],"method":"POST","size":3000,"url":"https://example.com"}},"data_stream_type":{"id":2}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Webhook - Event Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"header1:value1\",\n        \"header2:value2\"\n      ],\n      \"method\": \"POST\",\n      \"size\": 3000,\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Webhook - Event Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"header1:value1\",\n        \"header2:value2\"\n      ],\n      \"method\": \"POST\",\n      \"size\": 3000,\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Webhook - Event Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"header1:value1\",\n        \"header2:value2\"\n      ],\n      \"method\": \"POST\",\n      \"size\": 3000,\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Webhook - Event Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My Webhook Stream",
  "destination": {
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": {
      "headers": [
        "header1:value1",
        "header2:value2"
      ],
      "method": "POST",
      "size": 3000,
      "url": "https://example.com"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Webhook - Event Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"header1:value1\",\n        \"header2:value2\"\n      ],\n      \"method\": \"POST\",\n      \"size\": 3000,\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Webhook - Event Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My Webhook Stream",
  "destination": [
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": [
      "headers": ["header1:value1", "header2:value2"],
      "method": "POST",
      "size": 3000,
      "url": "https://example.com"
    ]
  ],
  "data_stream_type": ["id": 2]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Webhook - Event Data with Authorization

**Request**

```json
{
  "name": "My Authorized Webhook",
  "destination": {
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": {
      "headers": [
        "Authorization:Basic 0123456789ABCDEF"
      ],
      "url": "https://example.com"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Webhook - Event Data with Authorization
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My Authorized Webhook",
    "destination": {
        "connection_type": "RestAPI",
        "format": "Json",
        "credentials": {
            "headers": ["Authorization:Basic 0123456789ABCDEF"],
            "url": "https://example.com"
        }
    },
    "data_stream_type": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Webhook - Event Data with Authorization
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My Authorized Webhook","destination":{"connection_type":"RestAPI","format":"Json","credentials":{"headers":["Authorization:Basic 0123456789ABCDEF"],"url":"https://example.com"}},"data_stream_type":{"id":2}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Webhook - Event Data with Authorization
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My Authorized Webhook\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"Authorization:Basic 0123456789ABCDEF\"\n      ],\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Webhook - Event Data with Authorization
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My Authorized Webhook\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"Authorization:Basic 0123456789ABCDEF\"\n      ],\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Webhook - Event Data with Authorization
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My Authorized Webhook\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"Authorization:Basic 0123456789ABCDEF\"\n      ],\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Webhook - Event Data with Authorization
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My Authorized Webhook",
  "destination": {
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": {
      "headers": [
        "Authorization:Basic 0123456789ABCDEF"
      ],
      "url": "https://example.com"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Webhook - Event Data with Authorization
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My Authorized Webhook\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"headers\": [\n        \"Authorization:Basic 0123456789ABCDEF\"\n      ],\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Webhook - Event Data with Authorization
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My Authorized Webhook",
  "destination": [
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": [
      "headers": ["Authorization:Basic 0123456789ABCDEF"],
      "url": "https://example.com"
    ]
  ],
  "data_stream_type": ["id": 2]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Webhook - Alert Event Data

**Request**

```json
{
  "name": "My Alerts Webhook Stream",
  "destination": {
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": {
      "url": "https://example.com"
    }
  },
  "filters": [
    {
      "field": "alert",
      "value": [
        "true"
      ]
    }
  ],
  "data_stream_type": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Webhook - Alert Event Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My Alerts Webhook Stream",
    "destination": {
        "connection_type": "RestAPI",
        "format": "Json",
        "credentials": { "url": "https://example.com" }
    },
    "filters": [
        {
            "field": "alert",
            "value": ["true"]
        }
    ],
    "data_stream_type": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Webhook - Alert Event Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My Alerts Webhook Stream","destination":{"connection_type":"RestAPI","format":"Json","credentials":{"url":"https://example.com"}},"filters":[{"field":"alert","value":["true"]}],"data_stream_type":{"id":2}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Webhook - Alert Event Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My Alerts Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"alert\",\n      \"value\": [\n        \"true\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Webhook - Alert Event Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My Alerts Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"alert\",\n      \"value\": [\n        \"true\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Webhook - Alert Event Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My Alerts Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"alert\",\n      \"value\": [\n        \"true\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Webhook - Alert Event Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My Alerts Webhook Stream",
  "destination": {
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": {
      "url": "https://example.com"
    }
  },
  "filters": [
    {
      "field": "alert",
      "value": [
        "true"
      ]
    }
  ],
  "data_stream_type": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Webhook - Alert Event Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My Alerts Webhook Stream\",\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [\n    {\n      \"field\": \"alert\",\n      \"value\": [\n        \"true\"\n      ]\n    }\n  ],\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Webhook - Alert Event Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My Alerts Webhook Stream",
  "destination": [
    "connection_type": "RestAPI",
    "format": "Json",
    "credentials": ["url": "https://example.com"]
  ],
  "filters": [
    [
      "field": "alert",
      "value": ["true"]
    ]
  ],
  "data_stream_type": ["id": 2]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Amazon S3 - Usage Data

**Request**

```json
{
  "name": "My S3 Stream",
  "destination": {
    "connection_type": "S3",
    "format": "Csv",
    "credentials": {
      "bucket_name": "demo-bucket",
      "flush_size": 10000,
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_s3_data_stream",
      "rotate_interval": 10000
    }
  },
  "data_stream_type": {
    "id": 1
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Amazon S3 - Usage Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My S3 Stream",
    "destination": {
        "connection_type": "S3",
        "format": "Csv",
        "credentials": {
            "bucket_name": "demo-bucket",
            "flush_size": 10000,
            "region": "af-south-1",
            "role_arn": "arn:aws:iam:1234567890:role/role_for_s3_data_stream",
            "rotate_interval": 10000
        }
    },
    "data_stream_type": { "id": 1 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Amazon S3 - Usage Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My S3 Stream","destination":{"connection_type":"S3","format":"Csv","credentials":{"bucket_name":"demo-bucket","flush_size":10000,"region":"af-south-1","role_arn":"arn:aws:iam:1234567890:role/role_for_s3_data_stream","rotate_interval":10000}},"data_stream_type":{"id":1}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Amazon S3 - Usage Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My S3 Stream\",\n  \"destination\": {\n    \"connection_type\": \"S3\",\n    \"format\": \"Csv\",\n    \"credentials\": {\n      \"bucket_name\": \"demo-bucket\",\n      \"flush_size\": 10000,\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_s3_data_stream\",\n      \"rotate_interval\": 10000\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Amazon S3 - Usage Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My S3 Stream\",\n  \"destination\": {\n    \"connection_type\": \"S3\",\n    \"format\": \"Csv\",\n    \"credentials\": {\n      \"bucket_name\": \"demo-bucket\",\n      \"flush_size\": 10000,\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_s3_data_stream\",\n      \"rotate_interval\": 10000\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Amazon S3 - Usage Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My S3 Stream\",\n  \"destination\": {\n    \"connection_type\": \"S3\",\n    \"format\": \"Csv\",\n    \"credentials\": {\n      \"bucket_name\": \"demo-bucket\",\n      \"flush_size\": 10000,\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_s3_data_stream\",\n      \"rotate_interval\": 10000\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php Amazon S3 - Usage Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My S3 Stream",
  "destination": {
    "connection_type": "S3",
    "format": "Csv",
    "credentials": {
      "bucket_name": "demo-bucket",
      "flush_size": 10000,
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_s3_data_stream",
      "rotate_interval": 10000
    }
  },
  "data_stream_type": {
    "id": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Amazon S3 - Usage Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My S3 Stream\",\n  \"destination\": {\n    \"connection_type\": \"S3\",\n    \"format\": \"Csv\",\n    \"credentials\": {\n      \"bucket_name\": \"demo-bucket\",\n      \"flush_size\": 10000,\n      \"region\": \"af-south-1\",\n      \"role_arn\": \"arn:aws:iam:1234567890:role/role_for_s3_data_stream\",\n      \"rotate_interval\": 10000\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Amazon S3 - Usage Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My S3 Stream",
  "destination": [
    "connection_type": "S3",
    "format": "Csv",
    "credentials": [
      "bucket_name": "demo-bucket",
      "flush_size": 10000,
      "region": "af-south-1",
      "role_arn": "arn:aws:iam:1234567890:role/role_for_s3_data_stream",
      "rotate_interval": 10000
    ]
  ],
  "data_stream_type": ["id": 1]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### KeenIO - Usage Data

**Request**

```json
{
  "name": "My KeenIO Stream",
  "destination": {
    "connection_type": "KeenIO",
    "format": "Json",
    "credentials": {
      "collection_name": "MyDataStream",
      "project_id": "1234567890abcdef12345678",
      "size": 3000,
      "write_key": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
    }
  },
  "data_stream_type": {
    "id": 1
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python KeenIO - Usage Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My KeenIO Stream",
    "destination": {
        "connection_type": "KeenIO",
        "format": "Json",
        "credentials": {
            "collection_name": "MyDataStream",
            "project_id": "1234567890abcdef12345678",
            "size": 3000,
            "write_key": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
        }
    },
    "data_stream_type": { "id": 1 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript KeenIO - Usage Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My KeenIO Stream","destination":{"connection_type":"KeenIO","format":"Json","credentials":{"collection_name":"MyDataStream","project_id":"1234567890abcdef12345678","size":3000,"write_key":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}},"data_stream_type":{"id":1}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go KeenIO - Usage Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My KeenIO Stream\",\n  \"destination\": {\n    \"connection_type\": \"KeenIO\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"collection_name\": \"MyDataStream\",\n      \"project_id\": \"1234567890abcdef12345678\",\n      \"size\": 3000,\n      \"write_key\": \"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby KeenIO - Usage Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My KeenIO Stream\",\n  \"destination\": {\n    \"connection_type\": \"KeenIO\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"collection_name\": \"MyDataStream\",\n      \"project_id\": \"1234567890abcdef12345678\",\n      \"size\": 3000,\n      \"write_key\": \"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java KeenIO - Usage Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My KeenIO Stream\",\n  \"destination\": {\n    \"connection_type\": \"KeenIO\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"collection_name\": \"MyDataStream\",\n      \"project_id\": \"1234567890abcdef12345678\",\n      \"size\": 3000,\n      \"write_key\": \"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php KeenIO - Usage Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My KeenIO Stream",
  "destination": {
    "connection_type": "KeenIO",
    "format": "Json",
    "credentials": {
      "collection_name": "MyDataStream",
      "project_id": "1234567890abcdef12345678",
      "size": 3000,
      "write_key": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
    }
  },
  "data_stream_type": {
    "id": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp KeenIO - Usage Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My KeenIO Stream\",\n  \"destination\": {\n    \"connection_type\": \"KeenIO\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"collection_name\": \"MyDataStream\",\n      \"project_id\": \"1234567890abcdef12345678\",\n      \"size\": 3000,\n      \"write_key\": \"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift KeenIO - Usage Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My KeenIO Stream",
  "destination": [
    "connection_type": "KeenIO",
    "format": "Json",
    "credentials": [
      "collection_name": "MyDataStream",
      "project_id": "1234567890abcdef12345678",
      "size": 3000,
      "write_key": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
    ]
  ],
  "data_stream_type": ["id": 1]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Datadog - Event Data

**Request**

```json
{
  "name": "My Datadog Stream",
  "destination": {
    "connection_type": "Datadog",
    "format": "Json",
    "credentials": {
      "api_key": "0123456789abcdef0123456789abcdef01234567",
      "region": "US"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Datadog - Event Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My Datadog Stream",
    "destination": {
        "connection_type": "Datadog",
        "format": "Json",
        "credentials": {
            "api_key": "0123456789abcdef0123456789abcdef01234567",
            "region": "US"
        }
    },
    "data_stream_type": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Datadog - Event Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My Datadog Stream","destination":{"connection_type":"Datadog","format":"Json","credentials":{"api_key":"0123456789abcdef0123456789abcdef01234567","region":"US"}},"data_stream_type":{"id":2}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Datadog - Event Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My Datadog Stream\",\n  \"destination\": {\n    \"connection_type\": \"Datadog\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"api_key\": \"0123456789abcdef0123456789abcdef01234567\",\n      \"region\": \"US\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Datadog - Event Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My Datadog Stream\",\n  \"destination\": {\n    \"connection_type\": \"Datadog\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"api_key\": \"0123456789abcdef0123456789abcdef01234567\",\n      \"region\": \"US\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Datadog - Event Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My Datadog Stream\",\n  \"destination\": {\n    \"connection_type\": \"Datadog\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"api_key\": \"0123456789abcdef0123456789abcdef01234567\",\n      \"region\": \"US\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Datadog - Event Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My Datadog Stream",
  "destination": {
    "connection_type": "Datadog",
    "format": "Json",
    "credentials": {
      "api_key": "0123456789abcdef0123456789abcdef01234567",
      "region": "US"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Datadog - Event Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My Datadog Stream\",\n  \"destination\": {\n    \"connection_type\": \"Datadog\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"api_key\": \"0123456789abcdef0123456789abcdef01234567\",\n      \"region\": \"US\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Datadog - Event Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My Datadog Stream",
  "destination": [
    "connection_type": "Datadog",
    "format": "Json",
    "credentials": [
      "api_key": "0123456789abcdef0123456789abcdef01234567",
      "region": "US"
    ]
  ],
  "data_stream_type": ["id": 2]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Microsoft Azure EventHub - Event Data

**Request**

```json
{
  "name": "My EventHub Stream",
  "destination": {
    "connection_type": "EventHubs",
    "format": "Json",
    "credentials": {
      "connection_string": "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Microsoft Azure EventHub - Event Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My EventHub Stream",
    "destination": {
        "connection_type": "EventHubs",
        "format": "Json",
        "credentials": { "connection_string": "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name" }
    },
    "data_stream_type": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Microsoft Azure EventHub - Event Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My EventHub Stream","destination":{"connection_type":"EventHubs","format":"Json","credentials":{"connection_string":"Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name"}},"data_stream_type":{"id":2}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Microsoft Azure EventHub - Event Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My EventHub Stream\",\n  \"destination\": {\n    \"connection_type\": \"EventHubs\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"connection_string\": \"Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Microsoft Azure EventHub - Event Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My EventHub Stream\",\n  \"destination\": {\n    \"connection_type\": \"EventHubs\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"connection_string\": \"Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Microsoft Azure EventHub - Event Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My EventHub Stream\",\n  \"destination\": {\n    \"connection_type\": \"EventHubs\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"connection_string\": \"Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Microsoft Azure EventHub - Event Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My EventHub Stream",
  "destination": {
    "connection_type": "EventHubs",
    "format": "Json",
    "credentials": {
      "connection_string": "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name"
    }
  },
  "data_stream_type": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Microsoft Azure EventHub - Event Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My EventHub Stream\",\n  \"destination\": {\n    \"connection_type\": \"EventHubs\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"connection_string\": \"Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Microsoft Azure EventHub - Event Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My EventHub Stream",
  "destination": [
    "connection_type": "EventHubs",
    "format": "Json",
    "credentials": ["connection_string": "Endpoint=sb://eventhubnamespace.servicebus.windows.net/;SharedAccessKeyName=event-hub-send-allowed-policy-name;SharedAccessKey=SharedAccessKeyInBase64Encoded;EntityPath=event-hub-name"]
  ],
  "data_stream_type": ["id": 2]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Google Cloud Pub/Sub - Usage Data

**Request**

```json
{
  "name": "My PubSub Stream",
  "destination": {
    "connection_type": "PubSub",
    "format": "Json",
    "credentials": {
      "cps_project": "my-cps-project",
      "cps_topic": "my-cps-topic"
    }
  },
  "data_stream_type": {
    "id": 1
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Google Cloud Pub/Sub - Usage Data
import requests

url = "https://iot.telia.lt/api/v2/data_stream"

payload = {
    "name": "My PubSub Stream",
    "destination": {
        "connection_type": "PubSub",
        "format": "Json",
        "credentials": {
            "cps_project": "my-cps-project",
            "cps_topic": "my-cps-topic"
        }
    },
    "data_stream_type": { "id": 1 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Google Cloud Pub/Sub - Usage Data
const url = 'https://iot.telia.lt/api/v2/data_stream';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"My PubSub Stream","destination":{"connection_type":"PubSub","format":"Json","credentials":{"cps_project":"my-cps-project","cps_topic":"my-cps-topic"}},"data_stream_type":{"id":1}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Google Cloud Pub/Sub - Usage Data
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://iot.telia.lt/api/v2/data_stream"

	payload := strings.NewReader("{\n  \"name\": \"My PubSub Stream\",\n  \"destination\": {\n    \"connection_type\": \"PubSub\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"cps_project\": \"my-cps-project\",\n      \"cps_topic\": \"my-cps-topic\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Google Cloud Pub/Sub - Usage Data
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/data_stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"My PubSub Stream\",\n  \"destination\": {\n    \"connection_type\": \"PubSub\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"cps_project\": \"my-cps-project\",\n      \"cps_topic\": \"my-cps-topic\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Google Cloud Pub/Sub - Usage Data
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/data_stream")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"My PubSub Stream\",\n  \"destination\": {\n    \"connection_type\": \"PubSub\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"cps_project\": \"my-cps-project\",\n      \"cps_topic\": \"my-cps-topic\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php Google Cloud Pub/Sub - Usage Data
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/data_stream', [
  'body' => '{
  "name": "My PubSub Stream",
  "destination": {
    "connection_type": "PubSub",
    "format": "Json",
    "credentials": {
      "cps_project": "my-cps-project",
      "cps_topic": "my-cps-topic"
    }
  },
  "data_stream_type": {
    "id": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Google Cloud Pub/Sub - Usage Data
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"My PubSub Stream\",\n  \"destination\": {\n    \"connection_type\": \"PubSub\",\n    \"format\": \"Json\",\n    \"credentials\": {\n      \"cps_project\": \"my-cps-project\",\n      \"cps_topic\": \"my-cps-topic\"\n    }\n  },\n  \"data_stream_type\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Google Cloud Pub/Sub - Usage Data
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "My PubSub Stream",
  "destination": [
    "connection_type": "PubSub",
    "format": "Json",
    "credentials": [
      "cps_project": "my-cps-project",
      "cps_topic": "my-cps-topic"
    ]
  ],
  "data_stream_type": ["id": 1]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/data_stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```