Passer au contenu principal
POST
https://{tenantDomain}/api/v2
/
event-streams
Go
package example

import (
    context "context"

    management "github.com/auth0/go-auth0/management/management"
    client "github.com/auth0/go-auth0/management/management/client"
    option "github.com/auth0/go-auth0/management/management/option"
)

func do() {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    request := &management.EventStreamsCreateRequest{
        CreateEventStreamWebHookRequestContent: &management.CreateEventStreamWebHookRequestContent{
            Destination: &management.EventStreamWebhookDestination{
                Type: management.EventStreamWebhookDestinationTypeEnum(
                    "webhook",
                ),
                Configuration: &management.EventStreamWebhookConfiguration{
                    WebhookEndpoint: "webhook_endpoint",
                    WebhookAuthorization: &management.EventStreamWebhookAuthorizationResponse{
                        EventStreamWebhookBasicAuth: &management.EventStreamWebhookBasicAuth{
                            Method: management.EventStreamWebhookBasicAuthMethodEnum(
                                "basic",
                            ),
                            Username: "username",
                        },
                    },
                },
            },
        },
    }
    client.EventStreams.Create(
        context.TODO(),
        request,
    )
}
import { ManagementClient } from "auth0";

async function main() {
    const client = new ManagementClient({
        token: "<token>",
    });
    await client.eventStreams.create({
        destination: {
            type: "webhook",
            configuration: {
                webhookEndpoint: "webhook_endpoint",
                webhookAuthorization: {
                    method: "basic",
                    username: "username",
                },
            },
        },
    });
}
main();
import { ManagementClient } from "auth0";

async function main() {
    const client = new ManagementClient({
        token: "<token>",
    });
    await client.eventStreams.create({
        destination: {
            type: "webhook",
            configuration: {
                webhookEndpoint: "webhook_endpoint",
                webhookAuthorization: {
                    method: "basic",
                    username: "username",
                },
            },
        },
    });
}
main();
curl --request POST \
  --url https://{tenantDomain}/api/v2/event-streams \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "destination": {
    "type": "webhook",
    "configuration": {
      "webhook_endpoint": "<string>",
      "webhook_authorization": {
        "method": "basic",
        "username": "<string>"
      }
    }
  },
  "name": "<string>",
  "subscriptions": [
    {
      "event_type": "<string>"
    }
  ]
}
'
import requests

url = "https://{tenantDomain}/api/v2/event-streams"

payload = {
    "destination": {
        "type": "webhook",
        "configuration": {
            "webhook_endpoint": "<string>",
            "webhook_authorization": {
                "method": "basic",
                "username": "<string>"
            }
        }
    },
    "name": "<string>",
    "subscriptions": [{ "event_type": "<string>" }]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://{tenantDomain}/api/v2/event-streams",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'destination' => [
        'type' => 'webhook',
        'configuration' => [
                'webhook_endpoint' => '<string>',
                'webhook_authorization' => [
                                'method' => 'basic',
                                'username' => '<string>'
                ]
        ]
    ],
    'name' => '<string>',
    'subscriptions' => [
        [
                'event_type' => '<string>'
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
HttpResponse<String> response = Unirest.post("https://{tenantDomain}/api/v2/event-streams")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"destination\": {\n    \"type\": \"webhook\",\n    \"configuration\": {\n      \"webhook_endpoint\": \"<string>\",\n      \"webhook_authorization\": {\n        \"method\": \"basic\",\n        \"username\": \"<string>\"\n      }\n    }\n  },\n  \"name\": \"<string>\",\n  \"subscriptions\": [\n    {\n      \"event_type\": \"<string>\"\n    }\n  ]\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://{tenantDomain}/api/v2/event-streams")

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  \"destination\": {\n    \"type\": \"webhook\",\n    \"configuration\": {\n      \"webhook_endpoint\": \"<string>\",\n      \"webhook_authorization\": {\n        \"method\": \"basic\",\n        \"username\": \"<string>\"\n      }\n    }\n  },\n  \"name\": \"<string>\",\n  \"subscriptions\": [\n    {\n      \"event_type\": \"<string>\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "name": "<string>",
  "subscriptions": [
    {
      "event_type": "<string>"
    }
  ],
  "destination": {
    "type": "webhook",
    "configuration": {
      "webhook_endpoint": "<string>",
      "webhook_authorization": {
        "method": "basic",
        "username": "<string>"
      }
    }
  },
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z"
}

Autorisations

Authorization
string
header
requis

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Corps

destination
object
requis
name
string

Name of the event stream.

Required string length: 1 - 128
subscriptions
object[]

List of event types subscribed to in this stream.

Minimum array length: 1
status
enum<string>

Indicates whether the event stream is actively forwarding events.

Options disponibles:
enabled,
disabled
Maximum string length: 8

Réponse

Event Stream stream created successfully.

id
string<event-stream-id>

Unique identifier for the event stream.

Required string length: 26
name
string

Name of the event stream.

Required string length: 1 - 128
subscriptions
object[]

List of event types subscribed to in this stream.

Minimum array length: 1
destination
object
status
enum<string>

Indicates whether the event stream is actively forwarding events.

Options disponibles:
enabled,
disabled
Maximum string length: 8
created_at
string<date-time>

Timestamp when the event stream was created.

updated_at
string<date-time>

Timestamp when the event stream was last updated.