The AWS Marketplace API Reference was restructured. For more information about the supported API operations, see the AWS Marketplace API Reference.
Create a new SaaS contract agreement with upfront payment using an AWS SDK
The following code examples show how to create a new SaaS contract agreement with upfront payment.
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library
repository. package com.example.awsmarketplace.agreementapi.buyer; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.services.marketplaceagreement.MarketplaceAgreementClient; import software.amazon.awssdk.services.marketplaceagreement.model.AcceptAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.AcceptAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.ConfigurableUpfrontPricingTermConfiguration; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.Dimension; import software.amazon.awssdk.services.marketplaceagreement.model.Intent; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTermConfiguration; import software.amazon.awssdk.services.marketplaceagreement.model.TaxConfiguration; import utils.AgreementApiUtils; /** * Demonstrates how to create a SaaS agreement with CONTRACT pricing model with upfront payment * using the AWS Marketplace Agreement Service APIs. * * <p>Scenario: A buyer subscribes to a SaaS product using a ConfigurableUpfrontPricingTerm, * selecting an agreement duration and specifying quantities for multiple dimensions. * Tax estimation is enabled at the time of agreement creation. * * <p>Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offer: * <ul> * <li>{@code AGREEMENT_PROPOSAL_IDENTIFIER} — the agreementProposalId from the offer.</li> * <li>Term IDs (starting with {@code term-}) — found in the offer's term list.</li> * <li>{@code SELECTOR_VALUE} — duration for the agreement (e.g., {@code P12M} for 12 months).</li> * <li>{@code DIMENSION_1_KEY}, {@code DIMENSION_2_KEY} — dimension keys defined in the offer.</li> * <li>{@code DIMENSION_1_VALUE}, {@code DIMENSION_2_VALUE} — quantities for each dimension.</li> * </ul> */ public class NewSaaSContractWithUpfrontPayment { // The agreementProposalId from the offer. private static final String AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in your offer. private static final String CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P12M" for 12 months). private static final String SELECTOR_VALUE = "<your-selector-value>"; // First dimension key and quantity defined in your offer. private static final String DIMENSION_1_KEY = "<your-dimension-1-key>"; private static final int DIMENSION_1_VALUE = 10; // Second dimension key and quantity defined in your offer. private static final String DIMENSION_2_KEY = "<your-dimension-2-key>"; private static final int DIMENSION_2_VALUE = 20; // Term ID for the LegalTerm in your offer. private static final String LEGAL_TERM_ID = "<your-legal-term-id>"; // Tax estimation setting: "ENABLED" to include estimated taxes in the agreement. private static final String TAX_ESTIMATION = "ENABLED"; public static void main(String[] args) { createSaaSContractAgreement(); } /** * Creates a SaaS agreement with CONTRACT pricing model with configurable upfront pricing * for multiple dimensions and tax estimation. */ private static void createSaaSContractAgreement() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); RequestedTerm configurableUpfrontPricingTerm = RequestedTerm.builder() .id(CONFIGURABLE_UPFRONT_PRICING_TERM_ID) .configuration(RequestedTermConfiguration.fromConfigurableUpfrontPricingTermConfiguration( ConfigurableUpfrontPricingTermConfiguration.builder() .selectorValue(SELECTOR_VALUE) .dimensions(Dimension.builder() .dimensionKey(DIMENSION_1_KEY) .dimensionValue(DIMENSION_1_VALUE) .build(), Dimension.builder() .dimensionKey(DIMENSION_2_KEY) .dimensionValue(DIMENSION_2_VALUE) .build()) .build())) .build(); RequestedTerm legalTerm = RequestedTerm.builder() .id(LEGAL_TERM_ID) .build(); CreateAgreementRequestRequest createAgreementRequestRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(configurableUpfrontPricingTerm, legalTerm) .taxConfiguration(TaxConfiguration.builder().taxEstimation(TAX_ESTIMATION).build()) .agreementProposalIdentifier(AGREEMENT_PROPOSAL_IDENTIFIER) .build(); CreateAgreementRequestResponse createAgreementRequestResponse = marketplaceAgreementClient.createAgreementRequest(createAgreementRequestRequest); System.out.println("Agreement request created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId()); AcceptAgreementRequestRequest acceptAgreementRequestRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(createAgreementRequestResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse acceptAgreementRequestResponse = marketplaceAgreementClient.acceptAgreementRequest(acceptAgreementRequestRequest); System.out.println("SaaS agreement request with CONTRACT pricing model accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId()); } }-
For API details, see CreateAgreementRequest in AWS SDK for Java 2.x API Reference.
-
- JavaScript
-
- SDK for JavaScript (v3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library
repository. const { MarketplaceAgreementClient, CreateAgreementRequestCommand, AcceptAgreementRequestCommand, } = require("@aws-sdk/client-marketplace-agreement"); const { generateClientToken } = require("./utils/AgreementApiUtils"); /** * Demonstrates how to create a SaaS agreement with CONTRACT pricing model with upfront payment * using the AWS Marketplace Agreement Service APIs. * * Scenario: A buyer subscribes to a SaaS product using a ConfigurableUpfrontPricingTerm, * selecting an agreement duration and specifying quantities for multiple dimensions. * Tax estimation is enabled at the time of agreement creation. * * Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offer: * - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the offer. * - Term IDs (starting with "term-") — found in the offer's term list. * - SELECTOR_VALUE — duration for the agreement (e.g., "P12M" for 12 months). * - DIMENSION_1_KEY, DIMENSION_2_KEY — dimension keys defined in the offer. * - DIMENSION_1_VALUE, DIMENSION_2_VALUE — quantities for each dimension. */ // The agreementProposalId from the offer. const AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in your offer. const CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P12M" for 12 months). const SELECTOR_VALUE = "<your-selector-value>"; // First dimension key and quantity defined in your offer. const DIMENSION_1_KEY = "<your-dimension-1-key>"; const DIMENSION_1_VALUE = 10; // Second dimension key and quantity defined in your offer. const DIMENSION_2_KEY = "<your-dimension-2-key>"; const DIMENSION_2_VALUE = 20; // Term ID for the LegalTerm in your offer. const LEGAL_TERM_ID = "<your-legal-term-id>"; // Tax estimation setting: "ENABLED" to include estimated taxes in the agreement. const TAX_ESTIMATION = "ENABLED"; /** * Creates a SaaS agreement with CONTRACT pricing model with configurable upfront pricing * for multiple dimensions and tax estimation. */ async function createSaaSContractAgreement() { const client = new MarketplaceAgreementClient(); const configurableUpfrontPricingTerm = { id: CONFIGURABLE_UPFRONT_PRICING_TERM_ID, configuration: { configurableUpfrontPricingTermConfiguration: { selectorValue: SELECTOR_VALUE, dimensions: [ { dimensionKey: DIMENSION_1_KEY, dimensionValue: DIMENSION_1_VALUE }, { dimensionKey: DIMENSION_2_KEY, dimensionValue: DIMENSION_2_VALUE }, ], }, }, }; const legalTerm = { id: LEGAL_TERM_ID }; const createAgreementRequestResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [configurableUpfrontPricingTerm, legalTerm], taxConfiguration: { taxEstimation: TAX_ESTIMATION }, agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId); const acceptAgreementRequestResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: createAgreementRequestResponse.agreementRequestId, }) ); console.log("SaaS agreement request with CONTRACT pricing model accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId); } createSaaSContractAgreement();-
For API details, see CreateAgreementRequest in AWS SDK for JavaScript API Reference.
-
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library
repository. """ Demonstrates how to create a SaaS agreement with CONTRACT pricing model with upfront payment using the AWS Marketplace Agreement Service APIs. Scenario: A buyer subscribes to a SaaS product using a ConfigurableUpfrontPricingTerm, selecting an agreement duration and specifying quantities for multiple dimensions. Tax estimation is enabled at the time of agreement creation. Before running this sample, replace the placeholder constants below with values from your AWS Marketplace offer: - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the offer. - Term IDs (starting with term-) — found in the offer's term list. - SELECTOR_VALUE — duration for the agreement (e.g., P12M for 12 months). - DIMENSION_1_KEY, DIMENSION_2_KEY — dimension keys defined in the offer. - DIMENSION_1_VALUE, DIMENSION_2_VALUE — quantities for each dimension. """ import boto3 from utils.agreement_api_utils import generate_client_token class NewSaaSContractWithUpfrontPayment: # The agreementProposalId from the offer. AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>" # Term ID for the ConfigurableUpfrontPricingTerm in your offer. CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>" # Duration for the agreement (e.g., "P12M" for 12 months). SELECTOR_VALUE = "<your-selector-value>" # First dimension key and quantity defined in your offer. DIMENSION_1_KEY = "<your-dimension-1-key>" DIMENSION_1_VALUE = 10 # Second dimension key and quantity defined in your offer. DIMENSION_2_KEY = "<your-dimension-2-key>" DIMENSION_2_VALUE = 20 # Term ID for the LegalTerm in your offer. LEGAL_TERM_ID = "<your-legal-term-id>" # Tax estimation setting: "ENABLED" to include estimated taxes in the agreement. TAX_ESTIMATION = "ENABLED" @staticmethod def create_saas_contract_agreement(): """ Create a SaaS agreement with CONTRACT pricing model with configurable upfront pricing for multiple dimensions and tax estimation. """ client = boto3.client("marketplace-agreement") configurable_upfront_pricing_term = { "id": NewSaaSContractWithUpfrontPayment.CONFIGURABLE_UPFRONT_PRICING_TERM_ID, "configuration": { "configurableUpfrontPricingTermConfiguration": { "selectorValue": NewSaaSContractWithUpfrontPayment.SELECTOR_VALUE, "dimensions": [ { "dimensionKey": NewSaaSContractWithUpfrontPayment.DIMENSION_1_KEY, "dimensionValue": NewSaaSContractWithUpfrontPayment.DIMENSION_1_VALUE, }, { "dimensionKey": NewSaaSContractWithUpfrontPayment.DIMENSION_2_KEY, "dimensionValue": NewSaaSContractWithUpfrontPayment.DIMENSION_2_VALUE, }, ], } }, } legal_term = {"id": NewSaaSContractWithUpfrontPayment.LEGAL_TERM_ID} create_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[configurable_upfront_pricing_term, legal_term], taxConfiguration={"taxEstimation": NewSaaSContractWithUpfrontPayment.TAX_ESTIMATION}, agreementProposalIdentifier=NewSaaSContractWithUpfrontPayment.AGREEMENT_PROPOSAL_IDENTIFIER, ) agreement_request_id = create_response["agreementRequestId"] print("Agreement request created. AgreementRequestId: " + agreement_request_id) accept_response = client.accept_agreement_request( agreementRequestId=agreement_request_id ) print( "SaaS agreement request with CONTRACT pricing model accepted. AgreementId: " + accept_response["agreementId"] ) if __name__ == "__main__": NewSaaSContractWithUpfrontPayment.create_saas_contract_agreement()-
For API details, see CreateAgreementRequest in AWS SDK for Python (Boto3) API Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.