---
updatedAt: 2026-03-01T18:52:49.000Z
agentTools:
  siteIndex: https://techdocs.akamai.com/llms.txt
  projectIndex: https://techdocs.akamai.com/datastream2/llms.txt
---

# Create a stream for Splunk (v2)

```node Node
const EdgeGrid = require("akamai-edgegrid");
const os = require("os");
const edgercPath = os.homedir + "/.edgerc.txt";
const edgercSection = "default";
const eg = new EdgeGrid({
  path: edgercPath,
  section: edgercSection,
});

eg.auth({
  path: `/datastream-config-api/v2/log/streams`,
  method: "POST",
  headers: {
    "Content-Type": "application/json",

    Accept: "application/json",
  },
  body: {
    streamName: "DD Stream",
    groupId: 21484,
    contractId: "2-FGHIJ",
    notificationEmails: ["useremail1@domain.com", "useremail2@domain.com"],
    properties: [
      {
        propertyId: 349772,
      },
      {
        propertyId: 349770,
      },
    ],
    datasetFields: [
      {
        datasetFieldId: 1000,
      },
      {
        datasetFieldId: 1002,
      },
      {
        datasetFieldId: 1023,
      },
    ],
    deliveryConfiguration: {
      frequency: {
        intervalInSeconds: 30,
      },
      format: "STRUCTURED",
      fieldDelimiter: "SPACE",
    },
    destination: {
      destinationType: 'SPLUNK',
      compressLogs: true,
      displayName: 'Splunk_destination',
      endpoint: 'https://http-inputs-customer.splunkcloud.com/services/collector/raw',
      eventCollectorToken: '894-51c5-4b2e-888y-54fb-hh62',
      tlsHostname: 'kpiqaproxy.eastus.cloudapp.azure.com',
      caCert: '-----BEGIN CERTIFICATE-----\nMIIFnzCCA4egAwIBAgIUKO+hNjocWl ... RjDuaS6FRqLKUx\naf9d\n-----END CERTIFICATE-----',
      clientCert: '-----BEGIN CERTIFICATE-----\nMIIFMTCCAxkCFBrfjEylUee/1zuU3pkx33a3+Kl9MA0GC ... ep6\n0R3g8RB7v79PgqcBn70C5Lcdc93jDhBa2TQ==\n-----END CERTIFICATE-----',
      clientKey: '-----BEGIN PRIVATE KEY-----\nMIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggk ... ndYhVvhs9x5xsQwgvBhZM/P7LgjHJu6NYjVqdk4Y\n-----END PRIVATE KEY-----',
      customHeaderName: 'X-Splunk-Request-Channel',
      customHeaderValue: 'FE0ECFAD-13D5-401B-847D-77833BD77131'
    },
    collectMidgress: true,
  },
  qs: {
    activate: true,
  },
});
eg.send(function (error, response, body) {
  console.log(JSON.stringify(JSON.parse(body), null, 2));
});

```

```shell cURL
activate=true

egcurl --eg-section default --request POST \
  --url "https://$hostname/datastream-config-api/v2/log/streams?activate=$activate" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '
{
    "streamName": "DD Stream",
    "groupId": 21484,
    "contractId": "2-FGHIJ",
    "notificationEmails": [
        "useremail1@domain.com",
        "useremail2@domain.com"
    ],
    "properties": [
        {
            "propertyId": 349772
        },
        {
            "propertyId": 349770
        }
    ],
    "datasetFields": [
        {
            "datasetFieldId": 1000
        },
        {
            "datasetFieldId": 1002
        },
        {
            "datasetFieldId": 1023
        }
    ],
    "deliveryConfiguration": {
        "frequency": {
            "intervalInSeconds": 30
        },
        "format": "STRUCTURED",
        "fieldDelimiter": "SPACE"
    },
		"destination": {
          "destinationType": "SPLUNK",
          "compressLogs": true,
          "displayName": "Splunk_destination",
          "endpoint": "https://http-inputs-customer.splunkcloud.com/services/collector/raw",
          "eventCollectorToken": "894-51c5-4b2e-888y-54fb-hh62",
          "tlsHostname": "kpiqaproxy.eastus.cloudapp.azure.com",
          "caCert": "-----BEGIN CERTIFICATE-----\\nMIIFnzCCA4egAwIBAgIUKO+hNjocWl ... RjDuaS6FRqLKUx\\naf9d\\n-----END CERTIFICATE-----",
          "clientCert": "-----BEGIN CERTIFICATE-----\\nMIIFMTCCAxkCFBrfjEylUee/1zuU3pkx33a3+Kl9MA0GC ... ep6\\n0R3g8RB7v79PgqcBn70C5Lcdc93jDhBa2TQ==\\n-----END CERTIFICATE-----",
          "clientKey": "-----BEGIN PRIVATE KEY-----\\nMIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggk ... ndYhVvhs9x5xsQwgvBhZM/P7LgjHJu6NYjVqdk4Y\\n-----END PRIVATE KEY-----",
          "customHeaderName": "X-Splunk-Request-Channel",
          "customHeaderValue": "FE0ECFAD-13D5-401B-847D-77833BD77131"
     },
    "collectMidgress": true
}'
```

```python Python
import requests
import json
from akamai.edgegrid import EdgeGridAuth, EdgeRc
from urllib.parse import urljoin

edgerc = EdgeRc('~/.edgerc.txt')
section = 'default'
baseurl = 'https://%s' % edgerc.get(section, 'host')

session = requests.Session()
session.auth = EdgeGridAuth.from_edgerc(edgerc, section)
 

path = '/datastream-config-api/v2/log/streams'
headers = {
  "Content-Type": "application/json",

  "Accept": "application/json"}
payload = {
    "streamName": "DD Stream",
    "groupId": 21484,
    "contractId": "2-FGHIJ",
    "notificationEmails": [
        "useremail1@domain.com",
        "useremail2@domain.com"
    ],
    "properties": [
        {
            "propertyId": 349772
        },
        {
            "propertyId": 349770
        }
    ],
    "datasetFields": [
        {
            "datasetFieldId": 1000
        },
        {
            "datasetFieldId": 1002
        },
        {
            "datasetFieldId": 1023
        }
    ],
    "deliveryConfiguration": {
        "frequency": {
            "intervalInSeconds": 30
        },
        "format": "STRUCTURED",
        "fieldDelimiter": "SPACE"
    },
    "destination": {
        "destinationType": "SPLUNK",
        "compressLogs": true,
        "displayName": "Splunk_destination",
        "endpoint": "https://http-inputs-customer.splunkcloud.com/services/collector/raw",
        "eventCollectorToken": "894-51c5-4b2e-888y-54fb-hh62",
        "tlsHostname": "kpiqaproxy.eastus.cloudapp.azure.com",
        "caCert": "-----BEGIN CERTIFICATE-----\nMIIFnzCCA4egAwIBAgIUKO+hNjocWl ... RjDuaS6FRqLKUx\naf9d\n-----END CERTIFICATE-----",
        "clientCert": "-----BEGIN CERTIFICATE-----\nMIIFMTCCAxkCFBrfjEylUee/1zuU3pkx33a3+Kl9MA0GC ... ep6\n0R3g8RB7v79PgqcBn70C5Lcdc93jDhBa2TQ==\n-----END CERTIFICATE-----",
        "clientKey": "-----BEGIN PRIVATE KEY-----\nMIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggk ... ndYhVvhs9x5xsQwgvBhZM/P7LgjHJu6NYjVqdk4Y\n-----END PRIVATE KEY-----",
        "customHeaderName": "X-Splunk-Request-Channel",
        "customHeaderValue": "FE0ECFAD-13D5-401B-847D-77833BD77131"
    },
    "collectMidgress": true
} 
	querystring = {
  "activate": true
}  

result = session.get(urljoin(baseurl, path), headers=headers, json=payload, querystring=querystring)
print(result.status_code)
print(json.dumps(result.json(), indent=2)) 
```

```json Response Example
{
  "streamName": "DD Stream",
  "streamId": 7050,
  "streamVersion": 1,
  "groupId": 21484,
  "contractId": "2-FGHIJ",
  "properties": [
    {
      "propertyId": 349772,
      "propertyName": "example.com"
    },
    {
      "propertyId": 349770,
      "propertyName": "example.akamai.com"
    }
  ],
  "datasetFields": [
    {
      "datasetFieldId": 1000,
      "datasetFieldName": "CP code",
      "datasetFieldJsonKey": "cp"
    },
    {
      "datasetFieldId": 1002,
      "datasetFieldName": "Request ID",
      "datasetFieldJsonKey": "reqId"
    },
    {
      "datasetFieldId": 1023,
      "datasetFieldName": "Cookie",
      "datasetFieldJsonKey": "cookie"
    }
  ],
			"destination": {
        "destinationType": "SPLUNK",
        "compressLogs": true,
        "displayName": "Splunk_destination",
        "endpoint": "https://http-inputs-customer.splunkcloud.com/services/collector/raw",
        "customHeaderName": "X-Splunk-Request-Channel",
        "customHeaderValue": "FE0ECFAD-13D5-401B-847D-77833BD77131"
    },
  },
  	"deliveryConfiguration": {
    "format": "STRUCTURED",
    "fieldDelimiter": "SPACE",
    "frequency": {
      "intervalInSeconds": 30
    },
  },
  "latestVersion": 1,
  "productId": "Dynamic_Site_Accelerator",
  "streamStatus": "ACTIVATING",
  "createdBy": "johndoe",
  "createdDate": "2022-02-05T13:31:30Z",
  "modifiedBy": "johndoe",
  "modifiedDate": "2022-02-05T13:31:30Z",
  "notificationEmails": [
    "useremail1@domain.com",
    "useremail2@domain.com"
  ],
  "collectMidgress": true
  "mTlsenabled": true
}
```

# Set up authorization

<!-- node@1-9 -->

Before you can this API, you need to [Create authentication credentials](https://techdocs.akamai.com/developer/docs/set-up-authentication-credentials).

Then, you can use these code samples to apply the token values to your requests.

# Name the stream

<!-- node@19 -->
<!-- shell@9 -->

In the `streamName` field, enter a meaningful, human-readable name for your stream. It's useful for identification purposes.

# Fetch group and contract information

<!-- node@20-21 -->
<!-- shell@10-11 -->
<!-- python@21-22 -->

Run the [List groups](https://techdocs.akamai.com/datastream2/reference/get-groups) operation to get and store these values:

- the `groupId` of the group the product you want to monitor belongs to.

- `contractId` of the contract that belongs to the selected group.

# Set e-mail notifications

<!-- node@22 -->
<!-- shell@12-14 -->
<!-- python@23-25 -->

You can optionally enter a comma-delimited list of e-mail addresses to get notifications about events related to the stream (such as activating and deactivating it). 

If you omit this member, DataStream will not send e-mail notifications.

# Choose the properties

<!-- node@23-29 -->
<!-- shell@16-22 -->
<!-- python@27-33 -->

Fetch properties available for the group you previously selected. To do that, use the stored `groupId` in the [List properties by group](https://techdocs.akamai.com/datastream2/reference/get-group-properties) operation and store the `propertyId` values that you want to monitor in this stream. 

Enter them in the `properties` array of the request body.

# Choose the data set fields

<!-- node@31-40 -->
<!-- shell@24-33 -->
<!-- python@35-44 -->

Run the [List data set fields](https://techdocs.akamai.com/datastream2/reference/get-dataset-fields) operation and pick the `datasetFieldId` values of the fields that you want to monitor in your logs.

Values for these fields will appear in the log lines in the order you list them in the `datasetFields` array.

# Build the delivery configuration object

<!-- node@42-48 -->
<!-- shell@35-40 -->
<!-- python@46-51 -->

Build a `deliveryConfiguration` object where you specify how the logs are delivered to the destination.

# Set the log bundling frequency

<!-- node@43-44 -->
<!-- shell@36-37 -->
<!-- python@47-48 -->

In the `frequency` object, set the `intervalInSeconds` to `30` or `60` seconds to specify the time after which the API bundles your logs into a file and sends to a destination.

# Choose the log format and delimiter

<!-- node@46-47 -->
<!-- shell@39-40 -->
<!-- python@50-51 -->

Set the `format` that you want to receive your logs in, either `JSON` or `STRUCTURED`. 

For the `STRUCTURED` value, set the `fieldDelimiter` to `SPACE`. 

For the `JSON` value, skip the `fieldDelimiter` field.

# Configure the destination

<!-- node@49-61 -->
<!-- shell@42-53 -->
<!-- python@53-65 -->

Use the `destination` array to configure destination details, such as the upload path and authentication credentials.

# Enter the destination type

<!-- node@50 -->
<!-- shell@43 -->
<!-- python@54 -->

In `destinationType`, enter `SPLUNK`, the identifier for the Splunk destination in DataStream 2.

# Enable log compression

<!-- node@51 -->
<!-- shell@44 -->
<!-- python@55 -->

Optionally, enable gzip compression for a log file sent to a destination. If not set, this field's value is `false` by default.

# Name the destination

<!-- node@52 -->
<!-- shell@45 -->
<!-- python@56 -->

Enter a meaningful `displayName` to identify the destination.

# Set the endpoint URL

<!-- node@53 -->
<!-- shell@46 -->
<!-- python@57 -->

Enter the raw event Splunk URL where you want to store your logs. 

You can use Akamaized property hostnames as endpoint URLs. See [Stream logs to Splunk](https://techdocs.akamai.com/datastream2/docs/stream-splunk#akamaized-hostname-as-endpoint) for details.

# Enter the HEC token

<!-- node@54 -->
<!-- shell@47 -->
<!-- python@58 -->

Enter the the Event Collector token for your Splunk account. 

See [Usage of Event Collector token](https://docs.splunk.com/Documentation/Splunk/8.0.3/Data/UsetheHTTPEventCollector) in the Splunk documentation for details.

# Configure mTLS authentication

<!-- node@55-58 -->
<!-- shell@48-53 -->
<!-- python@59-62 -->

Optionally, you can configure mTLS authentication to improve stream security and prevent data delivery failures. This requires providing a TLS hostname, and authentication certificates.

# Enter a TLS hostname

<!-- node@55 -->
<!-- shell@48 -->
<!-- python@59 -->

Use this field to enter the hostname that verifies the server's certificate and matches the Subject Alternative Names (SANs) in the certificate. 

If not provided, DataStream fetches the hostname from the endpoint URL.

# Enter the CA certificate

<!-- node@56 -->
<!-- shell@49 -->
<!-- python@60 -->

Use this field to provide the certification authority (CA) certificate used to verify the origin server's certificate. 

If the certificate is not signed by a well-known certification authority, enter the CA certificate in the PEM format for verification. If you set this member, the `mTlsEnabled` property replaces it in the response as `true`.

# Enter the client certificate

<!-- node@57 -->
<!-- shell@50 -->
<!-- python@61 -->

Enter the PEM-formatted digital certificate you want to authenticate requests to your destination with. 

If you want to use mutual authentication, you need to provide both the client certificate and the client key. 

If you pass this member, the `mTlsEnabled` member replaces it in the response as true.

# Enter the client key

<!-- node@58 -->
<!-- shell@51 -->
<!-- python@62 -->

Enter the private key in the non-encrypted PKCS8 format that authenticates with the back-end server. 

If you want to use mutual authentication, you need to provide both the client certificate and the client key.

# Configure the custom header

<!-- node@59-60 -->
<!-- shell@52-53 -->
<!-- python@65-66 -->

You can optionally enter the name and value of the custom header accepted by your Splunk endpoint. See [Stream logs to Splunk](https://techdocs.akamai.com/datastream2/docs/stream-splunk#additional-options).

# Enable logging midgress traffic

<!-- node@62 -->
<!-- shell@55 -->
<!-- python@66 -->

Set `collectMidgress` to `true` if you want to to get data on traffic rom within the Akamai platform, such as between two edge servers.

# Activate the stream

<!-- node@64-65 -->
<!-- shell@1,4 -->
<!-- python@68-69 -->

Optionally, set the `activate` field to `true` to start activating the stream on request. The stream activates up to 60 minutes after making the request.

# Call the API



Run POST on the request URL with the request body object.

# Store the response values



The response's object returns the `streamId` and `streamVersion` values for the stream version you created.

You can use these values for other operations, such as [Get a stream](https://techdocs.akamai.com/datastream2/reference/get-stream) to list stream details.