Create Webhook

Create a new webhook for a business.

Request

use dodopayments_rust::{models::CreateWebhookRequest, to_pretty_json, DodoPaymentsClientBuilder};

#[tokio::main]

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = std::env::var("DODO_API_KEY")?;

    let client = DodoPaymentsClientBuilder::new()
        .bearer_token(&api_key)
        .enviroment("test_mode")
        .build()?;

    let resp = client
        .webhooks()
        .create()
        .body(CreateWebhookRequest {
            url: "https://example.com/webhook".to_string(),
            ..Default::default()
        })
        .send()
        .await?;

    println!("{}", to_pretty_json(&resp)?);

    Ok(())
}

Body

FieldTypeDescription
descriptionobject
disabledobjectCreate the webhook in a disabled state. Default is false
filter_typesarray<EventType>Filter events to the webhook. Webhook event will only be sent for events in the list.
headersobjectCustom headers to be passed
idempotency_keyobjectThe request's idempotency key
metadataobjectMetadata to be passed to the webhook Defaut is {}
rate_limitobject
urlstringUrl of the webhook

Responses

200 Status

FieldTypeDescription
created_atstringCreated at timestamp
descriptionstringAn example webhook name.
disabledobjectStatus of the webhook. If true, events are not sent
filter_typesobjectFilter events to the webhook. Webhook event will only be sent for events in the list.
idstringThe webhook's ID.
metadataobjectMetadata of the webhook
rate_limitobjectConfigured rate limit
updated_atstringUpdated at timestamp
urlstringUrl endpoint of the webhook

created Successfully