Create Product

Create a new product.

Request

use dodopayments_rust::{models::CreateProductRequest, 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
        .products()
        .create()
        .body(CreateProductRequest {
            name: "Premium Plan".to_string(),
            ..Default::default()
        })
        .send()
        .await?;

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

    Ok(())
}

Body

FieldTypeDescription
addonsobjectAddons available for subscription product
brand_idobjectBrand id for the product, if not provided will default to primary brand
credit_entitlementsobjectOptional credit entitlements to attach (max 3)
descriptionobjectOptional description of the product
digital_product_deliveryobject
license_key_activation_messageobjectOptional message displayed during license key activation
license_key_activations_limitobjectThe number of times the license key can be activated. Must be 0 or greater
license_key_durationobject
license_key_enabledobjectWhen true, generates and sends a license key to your customer. Defaults to false
metadataMetadataAdditional metadata for the product
namestringName of the product
pricePricePrice configuration for the product
tax_categoryTaxCategoryTax category applied to this product

Responses

200 Status

FieldTypeDescription
addonsobjectAvailable Addons for subscription products
brand_idstring
business_idstringUnique identifier for the business to which the product belongs.
created_atstringTimestamp when the product was created.
credit_entitlementsarray<CreditEntitlementMappingResponse>Attached credit entitlements with settings
descriptionobjectDescription of the product, optional.
digital_product_deliveryobject
imageobjectURL of the product image, optional.
is_recurringbooleanIndicates if the product is recurring (e.g., subscriptions).
license_key_activation_messageobjectMessage sent upon license key activation, if applicable.
license_key_activations_limitobjectLimit on the number of activations for the license key, if enabled.
license_key_durationobject
license_key_enabledbooleanIndicates whether the product requires a license key.
metadataMetadataAdditional custom data associated with the product
nameobjectName of the product, optional.
pricePricePricing information for the product.
product_collection_idobjectThe product collection ID this product belongs to, if any
product_idstringUnique identifier for the product.
tax_categoryTaxCategoryTax category associated with the product.
updated_atstringTimestamp when the product was last updated.

Product Created Successfully

422 Status

Invalid Request Object or Parameters

500 Status

Something went wrong :(