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 []StreamNewParamsSchemaFieldOptional
One of the following:
type StreamNewParamsSchemaFieldsInt32 struct{…}
Type StreamNewParamsSchemaFieldsInt32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsInt64 struct{…}
Type StreamNewParamsSchemaFieldsInt64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsFloat32 struct{…}
Type StreamNewParamsSchemaFieldsFloat32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsFloat64 struct{…}
Type StreamNewParamsSchemaFieldsFloat64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsBool struct{…}
Type StreamNewParamsSchemaFieldsBoolType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsString struct{…}
Type StreamNewParamsSchemaFieldsStringType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsBinary struct{…}
Type StreamNewParamsSchemaFieldsBinaryType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsTimestamp struct{…}
Type StreamNewParamsSchemaFieldsTimestampType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
Unit StreamNewParamsSchemaFieldsTimestampUnitOptional
One of the following:
const StreamNewParamsSchemaFieldsTimestampUnitSecond StreamNewParamsSchemaFieldsTimestampUnit = "second"
const StreamNewParamsSchemaFieldsTimestampUnitMillisecond StreamNewParamsSchemaFieldsTimestampUnit = "millisecond"
const StreamNewParamsSchemaFieldsTimestampUnitMicrosecond StreamNewParamsSchemaFieldsTimestampUnit = "microsecond"
const StreamNewParamsSchemaFieldsTimestampUnitNanosecond StreamNewParamsSchemaFieldsTimestampUnit = "nanosecond"
type StreamNewParamsSchemaFieldsJson struct{…}
Type StreamNewParamsSchemaFieldsJsonType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewParamsSchemaFieldsStruct struct{…}
type StreamNewParamsSchemaFieldsList struct{…}
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 []StreamNewResponseSchemaFieldOptional
One of the following:
type StreamNewResponseSchemaFieldsInt32 struct{…}
Type StreamNewResponseSchemaFieldsInt32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsInt64 struct{…}
Type StreamNewResponseSchemaFieldsInt64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsFloat32 struct{…}
Type StreamNewResponseSchemaFieldsFloat32Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsFloat64 struct{…}
Type StreamNewResponseSchemaFieldsFloat64Type
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsBool struct{…}
Type StreamNewResponseSchemaFieldsBoolType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsString struct{…}
Type StreamNewResponseSchemaFieldsStringType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsBinary struct{…}
Type StreamNewResponseSchemaFieldsBinaryType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsTimestamp struct{…}
Type StreamNewResponseSchemaFieldsTimestampType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
Unit StreamNewResponseSchemaFieldsTimestampUnitOptional
One of the following:
const StreamNewResponseSchemaFieldsTimestampUnitSecond StreamNewResponseSchemaFieldsTimestampUnit = "second"
const StreamNewResponseSchemaFieldsTimestampUnitMillisecond StreamNewResponseSchemaFieldsTimestampUnit = "millisecond"
const StreamNewResponseSchemaFieldsTimestampUnitMicrosecond StreamNewResponseSchemaFieldsTimestampUnit = "microsecond"
const StreamNewResponseSchemaFieldsTimestampUnitNanosecond StreamNewResponseSchemaFieldsTimestampUnit = "nanosecond"
type StreamNewResponseSchemaFieldsJson struct{…}
Type StreamNewResponseSchemaFieldsJsonType
MetadataKey stringOptional
Name stringOptional
Required boolOptional
SqlName stringOptional
type StreamNewResponseSchemaFieldsStruct struct{…}
type StreamNewResponseSchemaFieldsList struct{…}
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
}