Activate License

Activate a license for the user.

Request

use dodopayments_rust::{
    models::ActivateLicenseKeyRequest, 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
        .licenses()
        .activate()
        .body(ActivateLicenseKeyRequest {
            license_key: "lic_xxxxxxxxxx".to_string(),
            name: "My Device".to_string(),
        })
        .send()
        .await?;

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

    Ok(())
}

Body

FieldTypeDescription
license_keystring
namestring

Responses

201 Status

License key instance created

FieldTypeDescription
business_idstringBusiness ID
created_atstringCreation timestamp
customerobjectLimited customer details associated with the license key.
idstringLicense key instance ID
license_key_idstringAssociated license key ID
namestringInstance name
productobjectRelated product info. Present if the license key is tied to a product.

403 Status

License key cannot be activated (inactive)

404 Status

License key not found

422 Status

License key activation limit reached

500 Status

Something went wrong :(