Skip to content
Start here

Create Stream

client.Pipelines.Streams.New(ctx, params) (*StreamNewResponse, error)
POST/accounts/{account_id}/pipelines/v1/streams

Create a new Stream.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Pipelines Write
ParametersExpand Collapse
params StreamNewParams
AccountID param.Field[string]

Path param: Specifies the public ID of the account.

Name param.Field[string]

Body param: Specifies the name of the Stream.

maxLength128
minLength1
Format param.Field[StreamNewParamsFormat]Optional

Body param: Defines the data format of the events.

type StreamNewParamsFormatJson struct{…}
Type StreamNewParamsFormatJsonType
DecimalEncoding StreamNewParamsFormatJsonDecimalEncodingOptional
One of the following:
const StreamNewParamsFormatJsonDecimalEncodingNumber StreamNewParamsFormatJsonDecimalEncoding = "number"
const StreamNewParamsFormatJsonDecimalEncodingString StreamNewParamsFormatJsonDecimalEncoding = "string"
const StreamNewParamsFormatJsonDecimalEncodingBytes StreamNewParamsFormatJsonDecimalEncoding = "bytes"
TimestampFormat StreamNewParamsFormatJsonTimestampFormatOptional
One of the following:
const StreamNewParamsFormatJsonTimestampFormatRfc3339 StreamNewParamsFormatJsonTimestampFormat = "rfc3339"
const StreamNewParamsFormatJsonTimestampFormatUnixMillis StreamNewParamsFormatJsonTimestampFormat = "unix_millis"
Unstructured boolOptional
type StreamNewParamsFormatParquet struct{…}
Type StreamNewParamsFormatParquetType
Compression StreamNewParamsFormatParquetCompressionOptional
One of the following:
const StreamNewParamsFormatParquetCompressionUncompressed StreamNewParamsFormatParquetCompression = "uncompressed"
const StreamNewParamsFormatParquetCompressionSnappy StreamNewParamsFormatParquetCompression = "snappy"
const StreamNewParamsFormatParquetCompressionGzip StreamNewParamsFormatParquetCompression = "gzip"
const StreamNewParamsFormatParquetCompressionZstd StreamNewParamsFormatParquetCompression = "zstd"
const StreamNewParamsFormatParquetCompressionLz4 StreamNewParamsFormatParquetCompression = "lz4"
RowGroupBytes int64Optional
formatint64
minimum0
HTTP param.Field[StreamNewParamsHTTP]Optional

Body param

Authentication bool

Indicates that authentication is required for the HTTP endpoint.

Enabled bool

Indicates that the HTTP endpoint is enabled.

CORS StreamNewParamsHTTPCORSOptional

Specifies the CORS options for the HTTP endpoint.

Origins []stringOptional
Schema param.Field[StreamNewParamsSchema]Optional

Body param: Defines the schema of the events in the data stream.

Fields []SourceFieldOptional
One of the following:
type SourceFieldInt32 struct{…}
Type SourceFieldInt32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldInt64 struct{…}
Type SourceFieldInt64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldFloat32 struct{…}
Type SourceFieldFloat32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldFloat64 struct{…}
Type SourceFieldFloat64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldBool struct{…}
Type SourceFieldBoolType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldString struct{…}
Type SourceFieldStringType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldBinary struct{…}
Type SourceFieldBinaryType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldTimestamp struct{…}
Type SourceFieldTimestampType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
Unit SourceFieldTimestampUnitOptional
One of the following:
const SourceFieldTimestampUnitSecond SourceFieldTimestampUnit = "second"
const SourceFieldTimestampUnitMillisecond SourceFieldTimestampUnit = "millisecond"
const SourceFieldTimestampUnitMicrosecond SourceFieldTimestampUnit = "microsecond"
const SourceFieldTimestampUnitNanosecond SourceFieldTimestampUnit = "nanosecond"
type SourceFieldJson struct{…}
Type SourceFieldJsonType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldStruct struct{…}
Type SourceFieldStructType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldList struct{…}
Type SourceFieldListType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
Inferred boolOptional
WorkerBinding param.Field[StreamNewParamsWorkerBinding]Optional

Body param

Enabled bool

Indicates that the worker binding is enabled.

ReturnsExpand Collapse
type StreamNewResponse struct{…}
ID string

Indicates a unique identifier for this stream.

CreatedAt Time
formatdate-time
HTTP StreamNewResponseHTTP
Authentication bool

Indicates that authentication is required for the HTTP endpoint.

Enabled bool

Indicates that the HTTP endpoint is enabled.

CORS StreamNewResponseHTTPCORSOptional

Specifies the CORS options for the HTTP endpoint.

Origins []stringOptional
ModifiedAt Time
formatdate-time
Name string

Indicates the name of the Stream.

maxLength128
minLength1
Version int64

Indicates the current version of this stream.

WorkerBinding StreamNewResponseWorkerBinding
Enabled bool

Indicates that the worker binding is enabled.

Endpoint stringOptional

Indicates the endpoint URL of this stream.

formaturi
Format StreamNewResponseFormatOptional

Defines the data format of the events.

One of the following:
type StreamNewResponseFormatJson struct{…}
Type StreamNewResponseFormatJsonType
DecimalEncoding StreamNewResponseFormatJsonDecimalEncodingOptional
One of the following:
const StreamNewResponseFormatJsonDecimalEncodingNumber StreamNewResponseFormatJsonDecimalEncoding = "number"
const StreamNewResponseFormatJsonDecimalEncodingString StreamNewResponseFormatJsonDecimalEncoding = "string"
const StreamNewResponseFormatJsonDecimalEncodingBytes StreamNewResponseFormatJsonDecimalEncoding = "bytes"
TimestampFormat StreamNewResponseFormatJsonTimestampFormatOptional
One of the following:
const StreamNewResponseFormatJsonTimestampFormatRfc3339 StreamNewResponseFormatJsonTimestampFormat = "rfc3339"
const StreamNewResponseFormatJsonTimestampFormatUnixMillis StreamNewResponseFormatJsonTimestampFormat = "unix_millis"
Unstructured boolOptional
type StreamNewResponseFormatParquet struct{…}
Type StreamNewResponseFormatParquetType
Compression StreamNewResponseFormatParquetCompressionOptional
One of the following:
const StreamNewResponseFormatParquetCompressionUncompressed StreamNewResponseFormatParquetCompression = "uncompressed"
const StreamNewResponseFormatParquetCompressionSnappy StreamNewResponseFormatParquetCompression = "snappy"
const StreamNewResponseFormatParquetCompressionGzip StreamNewResponseFormatParquetCompression = "gzip"
const StreamNewResponseFormatParquetCompressionZstd StreamNewResponseFormatParquetCompression = "zstd"
const StreamNewResponseFormatParquetCompressionLz4 StreamNewResponseFormatParquetCompression = "lz4"
RowGroupBytes int64Optional
formatint64
minimum0
Schema StreamNewResponseSchemaOptional

Defines the schema of the events in the data stream.

Fields []SourceFieldOptional
One of the following:
type SourceFieldInt32 struct{…}
Type SourceFieldInt32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldInt64 struct{…}
Type SourceFieldInt64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldFloat32 struct{…}
Type SourceFieldFloat32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldFloat64 struct{…}
Type SourceFieldFloat64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldBool struct{…}
Type SourceFieldBoolType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldString struct{…}
Type SourceFieldStringType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldBinary struct{…}
Type SourceFieldBinaryType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldTimestamp struct{…}
Type SourceFieldTimestampType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
Unit SourceFieldTimestampUnitOptional
One of the following:
const SourceFieldTimestampUnitSecond SourceFieldTimestampUnit = "second"
const SourceFieldTimestampUnitMillisecond SourceFieldTimestampUnit = "millisecond"
const SourceFieldTimestampUnitMicrosecond SourceFieldTimestampUnit = "microsecond"
const SourceFieldTimestampUnitNanosecond SourceFieldTimestampUnit = "nanosecond"
type SourceFieldJson struct{…}
Type SourceFieldJsonType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldStruct struct{…}
Type SourceFieldStructType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type SourceFieldList struct{…}
Type SourceFieldListType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
Inferred boolOptional

Create Stream

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/pipelines"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  stream, err := client.Pipelines.Streams.New(context.TODO(), pipelines.StreamNewParams{
    AccountID: cloudflare.F("0123105f4ecef8ad9ca31a8372d0c353"),
    Name: cloudflare.F("my_stream"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", stream.ID)
}
{
  "result": {
    "id": "01234567890123457689012345678901",
    "created_at": "2019-12-27T18:11:19.117Z",
    "http": {
      "authentication": false,
      "enabled": true,
      "cors": {
        "origins": [
          "string"
        ]
      }
    },
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "my_stream",
    "version": 3,
    "worker_binding": {
      "enabled": true
    },
    "endpoint": "https://01234567890123457689012345678901.ingest.cloudflare.com/v1",
    "format": {
      "type": "json",
      "decimal_encoding": "number",
      "timestamp_format": "rfc3339",
      "unstructured": true
    },
    "schema": {
      "fields": [
        {
          "type": "int32",
          "metadata_key": "metadata_key",
          "name": "name",
          "required": true,
          "sql_name": "sql_name"
        }
      ],
      "inferred": true
    }
  },
  "success": true
}
Returns Examples
{
  "result": {
    "id": "01234567890123457689012345678901",
    "created_at": "2019-12-27T18:11:19.117Z",
    "http": {
      "authentication": false,
      "enabled": true,
      "cors": {
        "origins": [
          "string"
        ]
      }
    },
    "modified_at": "2019-12-27T18:11:19.117Z",
    "name": "my_stream",
    "version": 3,
    "worker_binding": {
      "enabled": true
    },
    "endpoint": "https://01234567890123457689012345678901.ingest.cloudflare.com/v1",
    "format": {
      "type": "json",
      "decimal_encoding": "number",
      "timestamp_format": "rfc3339",
      "unstructured": true
    },
    "schema": {
      "fields": [
        {
          "type": "int32",
          "metadata_key": "metadata_key",
          "name": "name",
          "required": true,
          "sql_name": "sql_name"
        }
      ],
      "inferred": true
    }
  },
  "success": true
}