Help Center/ EventGrid/ API Reference/ APIs/ Event Source Management/ Creating a Custom Event Source
Updated on 2023-05-24 GMT+08:00

Creating a Custom Event Source

Function

This API is used to create a custom event source, which must use a custom event channel.

URI

POST /v1/{project_id}/sources

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Tenant project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Minimum: 1

Maximum: 16384

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Name of the custom event source. The value must be unique under a tenant. Only lowercase letters, digits, periods (.), underscores (_), and hyphens (-) are allowed. It must start with a letter or digit and cannot start with hc..

Minimum: 1

Maximum: 128

description

No

String

Description of the event source.

Maximum: 255

channel_id

Yes

String

ID of the event channel to which the event source belongs.

type

No

String

Type of the event source.

Default: APPLICATION

Enumeration values:

  • APPLICATION

  • RABBITMQ

  • ROCKETMQ

detail

No

Object

Connection information encapsulated in JSON format in the message instance, such as the instance_id field of the RabbitMQ instance, vhost field of the virtual host, queue field, username, and password.

Response Parameters

Status code: 200

Table 4 Response header parameters

Parameter

Type

Description

X-Request-Id

String

This field is the request ID number for task tracking. Format is request_uuid-timestamp-hostname.

Table 5 Response body parameters

Parameter

Type

Description

id

String

ID of the event source.

name

String

Name of the event source.

label

String

Label of the event source.

description

String

Description of the event source.

provider_type

String

Type of the event source provider, which can be OFFICIAL (official cloud service event source) or CUSTOM (custom event source).

Enumeration values:

  • OFFICIAL

  • CUSTOM

event_types

Array of event_types objects

List of event types provided by the event source. Only the official cloud service event source provides event types.

created_time

String

UTC time when the event source is created.

updated_time

String

UTC time when the event source is updated.

channel_id

String

ID of the event channel to which the event source belongs.

channel_name

String

Name of the event channel to which the event source belongs.

type

String

Type of the event source.

detail

Object

Connection information encapsulated in JSON format in the message instance, such as the instance_id field of the RabbitMQ instance, vhost field of the virtual host, queue field, username, and password.

status

String

Status of the custom event source.

Enumeration values:

  • CREATE_FAILED

  • RUNNING

  • ERROR

Table 6 event_types

Parameter

Type

Description

name

String

Name of the event type.

description

String

Description of the event type.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 1

Maximum: 128

error_msg

String

Error message.

Minimum: 1

Maximum: 512

error_details

String

Error details.

Minimum: 1

Maximum: 1024

request_id

String

Request ID.

Minimum: 1

Maximum: 128

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 1

Maximum: 128

error_msg

String

Error message.

Minimum: 1

Maximum: 512

error_details

String

Error details.

Minimum: 1

Maximum: 1024

request_id

String

Request ID.

Minimum: 1

Maximum: 128

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 1

Maximum: 128

error_msg

String

Error message.

Minimum: 1

Maximum: 512

error_details

String

Error details.

Minimum: 1

Maximum: 1024

request_id

String

Request ID.

Minimum: 1

Maximum: 128

Status code: 404

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 1

Maximum: 128

error_msg

String

Error message.

Minimum: 1

Maximum: 512

error_details

String

Error details.

Minimum: 1

Maximum: 1024

request_id

String

Request ID.

Minimum: 1

Maximum: 128

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 1

Maximum: 128

error_msg

String

Error message.

Minimum: 1

Maximum: 512

error_details

String

Error details.

Minimum: 1

Maximum: 1024

request_id

String

Request ID.

Minimum: 1

Maximum: 128

Example Requests

Create an event source with a specified custom channel.

/v1/{project_id}/sources

{
  "name" : "name",
  "description" : "test",
  "channel_id" : "{{channel-id}}"
}

Example Responses

Status code: 400

{
  "error_code" : "EG.00014000",
  "error_msg" : "Bad request"
}

Status code: 401

{
  "error_code" : "EG.00014010",
  "error_msg" : "Incorrect token or token resolution failed"
}

Status code: 403

{
  "error_code" : "EG.00014030",
  "error_msg" : "No permissions to request this method"
}

Status code: 404

{
  "error_code" : "EG.00014040",
  "error_msg" : "Not request resource found"
}

Status code: 500

{
  "error_code" : "EG.00015000",
  "error_msg" : "Internal Server Error"
}

Status Codes

Status Code

Description

200

Operation successful.

400

Invalid request.

401

Unauthorized.

403

Access denied.

404

Resource not found.

500

Internal service error.

Error Codes

See Error Codes.