> 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.

# Modify existing data stream

PATCH https://iot.telia.lt/api/v2/data_stream/{data_stream_id}
Content-Type: application/json

Reference: https://docs.iot.telia.lt/developers/api/integrations/patch-v-2-data-stream

## 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

### Path parameters

- `data_stream_id` (string, required) — ID of a data stream.

### Body (application/json)

This endpoint expects an object.

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

## Response

### 202

Request accepted

## 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

Body will return list of validation errors

- `any`

## Types

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestination

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

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaFiltersItems

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

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaStatus

- `id` (double, required) — Status identifier
- `description` (string, optional) — Status description

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials

Destination credentials

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials0

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

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials1

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.

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials2

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.

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials3

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.

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials4

Credential fields for Datadog

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

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials5

Credential fields for Microsoft Azure EventHub

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

### ApiV2DataStreamDataStreamIdPatchRequestBodyContentApplicationJsonSchemaDestinationCredentials6

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

**Request**

```json
{
  "destination": {
    "connection_type": "RestAPI",
    "credentials": {
      "url": "https://example.com"
    }
  },
  "filters": [],
  "status": {
    "id": 2
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Change Data Stream configuration
import requests

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

payload = {
    "destination": {
        "connection_type": "RestAPI",
        "credentials": { "url": "https://example.com" }
    },
    "filters": [],
    "status": { "id": 2 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Change Data Stream configuration
const url = 'https://iot.telia.lt/api/v2/data_stream/a1b2c3d4';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"destination":{"connection_type":"RestAPI","credentials":{"url":"https://example.com"}},"filters":[],"status":{"id":2}}'
};

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

```go Change Data Stream configuration
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [],\n  \"status\": {\n    \"id\": 2\n  }\n}")

	req, _ := http.NewRequest("PATCH", 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 Change Data Stream configuration
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [],\n  \"status\": {\n    \"id\": 2\n  }\n}"

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

```java Change Data Stream configuration
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://iot.telia.lt/api/v2/data_stream/a1b2c3d4")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [],\n  \"status\": {\n    \"id\": 2\n  }\n}")
  .asString();
```

```php Change Data Stream configuration
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://iot.telia.lt/api/v2/data_stream/a1b2c3d4', [
  'body' => '{
  "destination": {
    "connection_type": "RestAPI",
    "credentials": {
      "url": "https://example.com"
    }
  },
  "filters": [],
  "status": {
    "id": 2
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Change Data Stream configuration
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/data_stream/a1b2c3d4");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"destination\": {\n    \"connection_type\": \"RestAPI\",\n    \"credentials\": {\n      \"url\": \"https://example.com\"\n    }\n  },\n  \"filters\": [],\n  \"status\": {\n    \"id\": 2\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Change Data Stream configuration
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "destination": [
    "connection_type": "RestAPI",
    "credentials": ["url": "https://example.com"]
  ],
  "filters": [],
  "status": ["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/a1b2c3d4")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```