### Authentication Example Source: https://docs.two.inc/docs/api/business-registration/business-registration-api This example demonstrates how to authenticate your requests to the Two Inc API using an API Key in the request header. ```APIDOC ## Authentication API Key: X-Api-Key For instructions on how to obtain API keys, visit this page. You will obtain two different keys, an initial one for testing in our sandbox environment and once ready, for production. Your API keys enables others to act on your behalf if they are able to obtain them, so make sure to keep them safe. Your API key is not to be shared with anyone, including in your version control system, client-side code, in public chatrooms and so on. The API key is applied in the request header. For example: ``` GET /something X-Api-Key: secret_test_aabbccddeeff0123456789 ``` API Keys have the following structure: `secret__` where: * `env` is determined by the environment (`prod` for production, `test` for test environments) * `key` is a random, URL-safe, 64-bit encoded text string containing 32 random bytes. Security Scheme Type:| apiKey ---|--- Header parameter name:| X-Api-Key ``` -------------------------------- ### Get Settlement Report Request Example Source: https://docs.two.inc/docs/api/checkout/get-merchant-statement-handler-get This example demonstrates how to make a GET request to the merchant statement endpoint to download a settlement report. Ensure you replace "" with your actual API key. ```http GET \ ## https://api.sandbox.two.inc/v2/merchant/statement ``` ```http GET /something X-Api-Key: secret_test_aabbccddeeff0123456789 ``` -------------------------------- ### C# Example: Fetching Company Data Source: https://docs.two.inc/docs/api/company/company-search This C# snippet demonstrates how to make a GET request to the Two Inc companies API to retrieve company data. Ensure you have HttpClient available. The response is printed to the console. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.sandbox.two.inc/companies/v2/company"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Successful Credit Check Response Example Source: https://docs.two.inc/docs/api/repay/credit-check-credit-check-post Example JSON response for a successful credit check. This includes minimum and maximum instalments, maximum instalment amount, decision, and currency. ```json { "minimum_instalments": 0, "maximum_instalments": 0, "maximum_instalment_amount": "string", "decision": "APPROVED", "currency": "DKK" } ``` -------------------------------- ### Payment Link Response Example Source: https://docs.two.inc/docs/api/checkout/get-order-payment-link-handler-get This is an example of a successful response containing the payment initiation link URL. The `payment_link` field will be null if a link cannot be generated due to unsupported configuration. ```json { "payment_link": "https://checkout.two.inc/payment/initiation?token=abc123" } ``` -------------------------------- ### Get Merchant Settlements V2 using HttpClient Source: https://docs.two.inc/docs/api/checkout/get-merchant-settlements-v-2-handler-get This C# example demonstrates how to make a GET request to the merchant settlements endpoint using HttpClient. Ensure you replace "" with your actual API key. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.sandbox.two.inc/v2/merchant/settlement"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Credit Check Request Body Example Source: https://docs.two.inc/docs/api/repay/credit-check-credit-check-post Example JSON body for the POST /credit-check request. Ensure all required fields are populated. ```json { "country_code": "AT", "national_identifier": "string", "company_name": "string", "amount": "string", "currency": "GBP", "instalment_period": "MONTHLY" } ``` -------------------------------- ### Create Partner Merchant Request Body Example Source: https://docs.two.inc/docs/api/marketplace/create-partner-merchant-handler-v-2-post An example JSON payload for creating a partner merchant. This includes details such as address, contact information, and payment provider specifics. ```json { "address_city": "London", "address_country_code": "GB", "address_lines": "Test Square", "address_postal_code": "AED 12A", "country_code": "GB", "email": "test@two.inc", "email_erp": "erp@two.inc", "email_invoice": "invoice@two.inc", "fixed_fee_per_order": "0.0", "legal_name": "Two B2B LIMITED", "logo_path": "https://test.com/test.png", "national_id": "13078389", "payment_provider_details": { "bank_account": { "branch_sort_code": "04-00-11", "country_code": "GB", "description": "Bank Account Test", "local_account_number": "31126819" } }, "percentage_fee_per_order": "2.0", "phone": "12345678", "phone_invoice": "12345670", "short_name": "testshortname", "website": "https://two.inc" } ``` -------------------------------- ### Successful Response Example Source: https://docs.two.inc/docs/api/repay/trigger-future-invoice-testing-send-invoices-post This is an example of a successful response when triggering future invoice generation. It returns a list of generated invoice IDs. ```json { "invoice_ids": [ "3fa85f64-5717-4562-b3fc-2c963f66afa6" ] } ``` -------------------------------- ### Get Buyer Credit Limits using HttpClient in C# Source: https://docs.two.inc/docs/api/limits/get-buyer-credit-limits-get This C# code snippet demonstrates how to make a GET request to retrieve buyer credit limits using `HttpClient`. Ensure you replace `` with your actual API key. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.sandbox.two.inc/limits/v1/company/:buyer_country_code/:buyer_organization_number"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Credit Builder URL Request Body Example Source: https://docs.two.inc/docs/api/limits/create-credit-builder-url-handler-post This is an example of the JSON body required to create a credit builder URL. It includes the canonical ID, return URL, and an optional company representative email. ```json { "canonical_id": "string", "return_url": "string", "company_representative_email": "user@example.com" } ``` -------------------------------- ### C# HttpClient Example Source: https://docs.two.inc/docs/api/repay/create-repayment-plan-plan-post Demonstrates how to create a repayment plan using HttpClient in C#. Ensure you include the 'X-Api-Key' header for authentication. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.sandbox.two.inc/repay/v1/plan"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var content = new StringContent("{ \"reference\": \"string\", \"description\": \"string\", \"total_repayment_amount\": \"string\", \"tax_subtotals\": [ { \"tax_rate\": \"string\", \"taxable_amount\": \"string\", \"tax_amount\": \"string\" } ], \"currency\": \"DKK\", \"consent_date\": \"2024-07-29\", \"line_items\": [ { \"name\": \"string\", \"description\": \"string\", \"product_identifiers\": [ { \"value\": \"string\", \"identifier_type\": \"EAN\" } ], \"unit_price_amount\": \"string\", \"unit_discount_amount\": \"string\", \"tax_rate\": \"string\", \"tax_class_name\": \"string\", \"quantity\": \"string\", \"quantity_unit_name\": \"string\", \"line_item_type\": \"DIGITAL\" } ], \"account_id\": \"string\", \"buyer_representative\": { \"first_name\": \"string\", \"last_name\": \"string\", \"phone_number\": \"string\", \"email\": \"user@example.com\" }, \"shipping_address\": { \"address_line_1\": \"string\", \"address_line_2\": \"string\", \"city\": \"string\", \"region\": \"string\", \"postal_code\": \"string\", \"country_code\": \"string\" }, \"terms\": { \"period\": \"YEARLY\", \"number_of_periods\": 0, \"start_month\": 0 } }", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Open Signup Popup Source: https://docs.two.inc/docs/api/business-registration/business-registration-api Obtain necessary tokens for registration and autofill write access, then open the signup popup. The popup guides the user through registration or uses saved details if available. ```shell # Back-end: Get tokens for registration and autofill write access AUTH_TOKEN=$(curl -s "$API_BASE/registry/v1/delegation" \ -H "$AUTH_HEADERS" \ -H "Content-Type: application/json" \ -d '{"verify_returning_buyer": true, "create_proposal": true}' \ -D - -o /dev/null | grep -i "two-delegated-authority-token:" | cut -d' ' -f2 | tr -d '\r') AUTOFILL_WRITE_TOKEN=$(curl -s "$API_BASE/autofill/v1/delegation" \ -H "$AUTH_HEADERS" \ -H "Content-Type: application/json" \ -d '{"write_current_buyer": true}' \ -D - -o /dev/null | grep -i "two-delegated-authority-token:" | cut -d' ' -f2 | tr -d '\r') # Front-end: Open the signup popup (complete the flow in the browser) open "$CHECKOUT_BASE/soletrader/signup?authToken=$AUTH_TOKEN&autofillToken=$AUTOFILL_WRITE_TOKEN" ``` -------------------------------- ### Start Returning Buyer Verification Source: https://docs.two.inc/docs/api/business-registration/returning-buyer-start-verification-handler-post Checks for an existing business registration using an email address and initiates verification if found. Use this to identify returning buyers before creating a new proposal. A 404 response means no existing registration was found, and you should proceed with new buyer proposal creation. Requires a delegation token with `verify_returning_buyer` permission. ```APIDOC ## POST /registry/v1/proposal/returning-buyer/verification ### Description Checks if a business is already registered with the provided email address. If found, initiates email verification by sending a verification code to that address. Use this endpoint to identify returning buyers before creating a new proposal. If a 404 is returned, no existing registration was found and you should proceed with proposal creation for a new buyer. Requires a delegation token with `verify_returning_buyer` permission. ### Method POST ### Endpoint /registry/v1/proposal/returning-buyer/verification ### Responses * 201: Verification initiated. A verification code has been sent to the email address. * 400: Invalid request. * 404: No existing business found for this email. Proceed with new registration. ``` -------------------------------- ### Instalments Invoiced Webhook Payload Example Source: https://docs.two.inc/docs/api/webhooks/instalments-invoicedinstalments-invoiced-post This JSON object represents the payload received when an invoice with instalments is created. It includes details about the invoice, merchant, tax subtotals, and individual instalments. ```json { "specversion": "1.0", "id": "01FBJ0PYJ7931K0CJ6GMP8N3WG", "type": "instalments.invoiced.v1", "time": "2023-06-21T12:34:56.123456", "source": "webhooks.two.inc", "subject": "instalment_account/044d6cf0-0f51-11ec-82a8-0242ac130003", "twomerchantid":"b6b9d5d1-f6b7-4e15-9703-9c32c6e5c1c2", "data": { "invoice_id": "e39f3206-0f94-4b9d-9f8f-1b2bae1e2bc9", "merchant_id": "b6b9d5d1-f6b7-4e15-9703-9c32c6e5c1c2", "issue_date": "2023-06-05T12:34:56.123456", "due_date": "2023-06-05T12:34:56.123456", "invoice_number": "90000001", "instalment_account_id": "044d6cf0-0f51-11ec-82a8-0242ac130003", "gross_amount": "1000.00", "tax_subtotals": [ { "tax_rate": "0.250000", "taxable_amount": "500.00", "tax_amount": "125.00" }, { "tax_rate": "0.000000", "taxable_amount": "500.00", "tax_amount": "0.00" } ], "instalments": [ { "plan_id": "b6c9de3c-5d51-4a9d-89b1-63e1a9f7c5e5", "instalment_id": "a0f4bc40-8c5d-4b80-8c40-7d1f0b5a1f74" }, { "plan_id": "ff6b6e3e-5e0e-4d27-bc62-4e5a3a80e7f4", "instalment_id": "d2f5f79b-1e5a-4fe3-9e53-0b3a4b2c1c1b" } ] } } ``` -------------------------------- ### Instalments Invoiced Webhook Payload Source: https://docs.two.inc/docs/api/webhooks/instalments-invoicedinstalments-invoiced-post This is an example of the payload received when the instalments.invoiced.v1 webhook is triggered. It includes invoice details, tax subtotals, and instalment information. ```APIDOC ## Instalments Invoiced Webhook ### Description Occurs when an invoice including one or more instalments is created. ### Payload The `data` object in the payload contains IDs that indicate the invoice that has been created and the associated merchant and instalment plan. Also note the following child objects within the payload: * `tax_subtotals`: Contains specific information about the tax subtotals of the invoice. * `instalments`: Contains specific information about the instalments comprising the invoice. ### Example ```json { "specversion": "1.0", "id": "01FBJ0PYJ7931K0CJ6GMP8N3WG", "type": "instalments.invoiced.v1", "time": "2023-06-21T12:34:56.123456", "source": "webhooks.two.inc", "subject": "instalment_account/044d6cf0-0f51-11ec-82a8-0242ac130003", "twomerchantid":"b6b9d5d1-f6b7-4e15-9703-9c32c6e5c1c2", "data": { "invoice_id": "e39f3206-0f94-4b9d-9f8f-1b2bae1e2bc9", "merchant_id": "b6b9d5d1-f6b7-4e15-9703-9c32c6e5c1c2", "issue_date": "2023-06-05T12:34:56.123456", "due_date": "2023-06-05T12:34:56.123456", "invoice_number": "90000001", "instalment_account_id": "044d6cf0-0f51-11ec-82a8-0242ac130003", "gross_amount": "1000.00", "tax_subtotals": [ { "tax_rate": "0.250000", "taxable_amount": "500.00", "tax_amount": "125.00" }, { "tax_rate": "0.000000", "taxable_amount": "500.00", "tax_amount": "0.00" } ], "instalments": [ { "plan_id": "b6c9de3c-5d51-4a9d-89b1-63e1a9f7c5e5", "instalment_id": "a0f4bc40-8c5d-4b80-8c40-7d1f0b5a1f74" }, { "plan_id": "ff6b6e3e-5e0e-4d27-bc62-4e5a3a80e7f4", "instalment_id": "d2f5f79b-1e5a-4fe3-9e53-0b3a4b2c1c1b" } ] } } ``` ### Responses * 200 - Successful Response * 422 - Validation Error ``` -------------------------------- ### Merchant Onboarding and Request Headers Source: https://docs.two.inc/docs/api/marketplace/two-marketplace-api Use POST /partner/v1/merchant to onboard a new merchant. Store the returned merchant_id to include in subsequent requests using the X-Merchant-Id header. ```http GET /something X-Api-Key: X-Merchant-Id: ``` -------------------------------- ### C# Example for Creating a Trade Account Customer Source: https://docs.two.inc/docs/api/trade-account-v3/create-trade-account-customer-handler-post This snippet demonstrates how to create a trade account customer using HttpClient in C#. Ensure you replace '' with your actual API key. The request includes customer contact and billing information. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.sandbox.two.inc/trade-account/v3/customer"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var content = new StringContent("{\n \"canonical_id\": \"string\",\n \"country_code\": \"AD\",\n \"organization_number\": \"string\",\n \"merchant_customer_id\": \"string\",\n \"contact_persons\": [\n {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"phone_number\": \"+44XXXXXXXXXX\",\n \"email\": \"johndoe0112358@gmail.com\"\n }\n ],\n \"invoice_email_addresses\": [\n \"user@example.com\"\n ],\n \"invoice_billing_address\": {\n \"city\": \"Berlin\",\n \"country\": \"DE\",\n \"postal_code\": \"string\",\n \"region\": \"string\",\n \"street_address\": \"Lombard St 10\"\n },\n \"use_billing_address_for_shipping\": false,\n \"trade_name\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Update Instalment Source: https://docs.two.inc/docs/api/repay/update-instalment-plan-repayment-plan-id-instalment-instalment-id-put Updates a specific instalment by its ID within a repayment plan. ```APIDOC ## PUT /plan/:repayment_plan_id/instalment/:instalment_id ### Description Updates a specific instalment by its ID within a repayment plan. ### Method PUT ### Endpoint /plan/:repayment_plan_id/instalment/:instalment_id ### Parameters #### Path Parameters - **repayment_plan_id** (string) - Required - The ID of the repayment plan. - **instalment_id** (string) - Required - The ID of the instalment to update. ### Responses #### Success Response (204) No content, indicating the instalment was successfully updated. #### Error Response (422) Unprocessable Entity, indicating a validation error with the request. ``` -------------------------------- ### Get all marketplace merchants Source: https://docs.two.inc/docs/api/marketplace/two-marketplace-api Retrieve a list of all merchants associated with your marketplace by sending a GET request to the /partner/v1/merchant endpoint. ```APIDOC ## GET /partner/v1/merchant ### Description Retrieves a list of all merchants in the marketplace. ### Method GET ### Endpoint /partner/v1/merchant ### Headers - **X-Api-Key** (string) - Required - Your API key for authentication. ### Response #### Success Response (200 OK) - **merchants** (array) - A list of merchant objects. - **id** (string) - The unique identifier for the merchant. - **merchant_data** (object) - The information of the merchant. ``` -------------------------------- ### API Key Authentication Example Source: https://docs.two.inc/docs/api/limits/two-limits-api Demonstrates how to apply the API key in the request header for authentication. Ensure your API key is kept secure and not shared. ```http GET /something X-Api-Key: secret_test_aabbccddeeff0123456789 ``` -------------------------------- ### Create and onboard merchant with Two Source: https://docs.two.inc/docs/api/marketplace/two-marketplace-api Sign up a new merchant with Two by sending a POST request to the /partner/v1/merchant endpoint with the required information. The merchant's ID from the response is crucial for subsequent requests on behalf of the merchant. ```APIDOC ## POST /partner/v1/merchant ### Description Creates a new merchant with Two. ### Method POST ### Endpoint /partner/v1/merchant ### Request Body - **merchant_data** (object) - Required - The information required to sign up a merchant. ### Response #### Success Response (201 Created) - **id** (string) - The unique identifier for the newly created merchant. - **merchant_data** (object) - The information of the created merchant. ``` -------------------------------- ### API Key Authorization Example (cURL) Source: https://docs.two.inc/docs/api/checkout/create-order-handler-post This cURL command shows how to pass the API key in the header for authentication. ```curl curl -X GET "https://api.example.com/something" -H "X-Api-Key: secret_test_aabbccddeeff0123456789" ``` -------------------------------- ### API Key Authorization Example Source: https://docs.two.inc/docs/api/checkout/get-order-payment-link-handler-get Demonstrates how to include the API key in the request header for authentication. The API key should be kept secure and not shared. ```http GET /something X-Api-Key: secret_test_aabbccddeeff0123456789 ``` -------------------------------- ### C# HttpClient Example for Invoice Creation Source: https://docs.two.inc/docs/api/checkout/invoice-creation-handler-post Demonstrates how to create an invoice using HttpClient in C#. Ensure you replace \"\" with your actual API key. The request body specifies order IDs and merchant references. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.sandbox.two.inc/invoicing/v0/invoice"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var content = new StringContent("{\n \"order_ids\": [\n \"string\"\n ],\n \"merchant_order_id\": \"string\",\n \"merchant_reference\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Credit Check Validation Error Response Example Source: https://docs.two.inc/docs/api/repay/credit-check-credit-check-post Example JSON response for a validation error during a credit check. It details the location, message, and type of each error. ```json { "detail": [ { "loc": [ "string", 0 ], "msg": "string", "type": "string" } ] } ``` -------------------------------- ### Create Order POST Request Source: https://docs.two.inc/docs/api/checkout/create-order-handler-post This C# snippet demonstrates how to create an order by sending a POST request to the Two Inc API. It includes setting up the HttpClient, HttpRequestMessage, headers, and the JSON content for the order details. Ensure you replace placeholder values like '' and other YOUR_* values with your actual data. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.sandbox.two.inc/v1/order"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var content = new StringContent("{ \"billing_address\": { \"city\": \"Menlo Park\", \"country\": \"GB\", \"organization_name\": \"TWO B2B LTD\", \"postal_code\": \"SW17 8BY\", \"references\": { \"attn\": \"yo\", \"co\": \"Company CEO\", \"reference\": \"Firs floor office\" }, \"region\": \"GB\", \"street_address\": \"1 Hacker Way\" }, \"buyer\": { \"company\": { \"company_name\": \"TWO B2B LTD\", \"country_prefix\": \"GB\", \"organization_number\": \"13078389\" }, \"representative\": { \"email\": \"john.doe@twob2bltd.com\", \"first_name\": \"John\", \"last_name\": \"Doe\", \"phone_number\": \"+447516498321\" } }, \"currency\": \"GBP\", \"discount_amount\": \"0\", \"discount_rate\": \"0\", \"gross_amount\": \"120.00\", \"line_items\": [ { \"description\": \"Blue whale poster\", \"details\": { \"barcodes\": [ { \"type\": \"SKU\", \"value\": \"YOUR_BARCODE_VALUE\" }, { \"type\": \"UPC\", \"value\": \"YOUR_BARCODE_VALUE\" } ], \"brand\": \"Whale Posters INC\", \"categories\": [ \"YOUR_CATEGORY_A\", \"YOUR_CATEGORY_B\" ], \"part_number\": \"MANUFACTURER_PART_NUMBER\" }, \"discount_amount\": \"0\", \"gross_amount\": \"120.00\", \"image_url\": \"https://www.exampleobjects.com/product-image-800x600\", \"line_item_reference\": \"YOUR_LINE_ITEM_REFERENCE\", \"name\": \"Whale poster\", \"net_amount\": \"100.00\", \"product_page_url\": \"https://www.example.com/products/######\", \"quantity\": 1, \"quantity_unit\": \"pcs\", \"tax_amount\": \"20.00\", \"tax_class_name\": \"VAT 20%\", \"tax_rate\": \"0.20\", \"type\": \"PHYSICAL\", \"unit_price\": \"100\" } ], \"merchant_additional_info\": \"Additional line item information\", \"merchant_order_id\": \"YOUR_MERCHANT_ORDER_ID\", \"merchant_reference\": \"YOUR_MERCHANT_REFERENCE\", \"merchant_urls\": { \"merchant_cancel_order_url\": \"YOUR_MERCHANT_URL/cancel-order\", \"merchant_confirmation_url\": \"YOUR_MERCHANT_URL/confimation\", \"merchant_edit_order_url\": \"YOUR_MERCHANT_URL/edit-order\", \"merchant_invoice_url\": \"YOUR_MERCHANT_URL/invoice\", \"merchant_order_verification_failed_url\": \"YOUR_MERCHANT_URL/order-verification-failed\", \"merchant_order_verification_pending_url\": \"YOUR_MERCHANT_URL/pending-order\", \"merchant_shipping_document_url\": \"YOUR_MERCHANT_URL/shipping-document\" }, \"net_amount\": \"100.00\", \"order_intent_id\": \"ORDER_INTENT_TRACKING_ID\", \"shipping_address\": { \"city\": \"Menlo Park\", \"country\": \"GB\", \"organization_name\": \"TWO B2B LTD\", \"postal_code\": \"SW17 8BY\", \"references\": { \"attn\": \"The receptionist\", \"co\": \"Company CEO\", \"reference\": \"First floor office\" }, \"region\": \"GB\", \"street_address\": \"1 Hacker Way\" }, \"shipping_details\": { \"carrier_name\": \"Example carrier\", \"carrier_tracking_url\": \"https://example.com/tracking-url/\", \"expected_delivery_date\": \"2026-01-08\", \"tracking_number\": \"SHIPPING_TRACKING_NUMBER\" }, \"tax_amount\": \"20.00\" }", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Create Repayment Plan Source: https://docs.two.inc/docs/api/repay/create-repayment-plan-plan-post Allows the creation of a repayment plan with specified terms and instalments. It details the structure for individual instalments, including amounts, dates, and tax information. ```APIDOC ## POST /repay/create-repayment-plan ### Description Creates a new repayment plan with specified terms and instalments. ### Method POST ### Endpoint /repay/create-repayment-plan ### Parameters #### Request Body - **invoice_grouping_key** (string) - Optional - Non-empty grouping key to put instalments into separate invoices. - **instalments** (object[]) - Required - The instalments of the repayment plan. Must contain at least one element. - **id** (string) - Optional - ID generated by Two when creating the resource. Max 40 characters. Must match regex `^[a-zA-Z0-9\-_]+$`. - **reference** (string) - Required - The merchant's ID or reference for this instalment. Max 40 characters. Must match regex `^[a-zA-Z0-9\-_]+$`. - **invoice_issue_date** (date) - Required - The date that the invoice containing this installment will be issued. - **description** (string) - Optional - Description for the instalment. - **repayment_amount** (decimal) - Required - Strictly positive decimal number (greater than zero). JSON number or string of the form '0.00'. Must match regex `^-?[0-9]+(\.[0-9]{0,2})?`. - **tax_subtotals** (object[]) - Required - Array of tax subtotals for the instalment. - **tax_rate** (decimal) - Required - Tax rate given as a decimal number between 0 and 1 with 6 decimals precision. Must match regex `^-?[0-9]+(\.[0-9]{0,6})?`. - **taxable_amount** (decimal) - Required - Decimal number. JSON number or string of the form '0.00'. Must match regex `^-?[0-9]+(\.[0-9]{0,2})?`. - **tax_amount** (decimal) - Required - Decimal number. JSON number or string of the form '0.00'. Must match regex `^-?[0-9]+(\.[0-9]{0,2})?`. ### Request Example ```json { "invoice_grouping_key": "string", "instalments": [ { "id": "string", "reference": "string", "invoice_issue_date": "2024-07-29", "description": "string", "repayment_amount": "string", "tax_subtotals": [ { "tax_rate": "string", "taxable_amount": "string", "tax_amount": "string" } ] } ] } ``` ### Response #### Success Response (200) - **id** (string) - ID generated by Two when creating the resource. - **reference** (string) - The merchant's ID or reference for this instalment. - **description** (string) - Description for the instalment. - **total_repayment_amount** (string) - Total repayment amount for the plan. - **tax_subtotals** (object[]) - Array of tax subtotals for the plan. - **tax_rate** (string) - Tax rate. - **taxable_amount** (string) - Taxable amount. - **tax_amount** (string) - Tax amount. - **currency** (string) - Currency code (e.g., DKK). - **consent_date** (date) - Date of consent. - **line_items** (object[]) - Array of line items. - **name** (string) - Name of the line item. - **description** (string) - Description of the line item. - **product_identifiers** (object[]) - Array of product identifiers. - **value** (string) - Value of the product identifier. - **identifier_type** (string) - Type of the product identifier (e.g., EAN). - **unit_price_amount** (string) - Unit price amount. - **unit_discount_amount** (string) - Unit discount amount. - **tax_rate** (string) - Tax rate for the line item. - **tax_class_name** (string) - Tax class name. - **quantity** (string) - Quantity of the item. - **quantity_unit_name** (string) - Unit name for the quantity. - **line_item_type** (string) - Type of the line item (e.g., DIGITAL). - **account_id** (string) - Account ID. - **buyer_representative** (object) - Buyer representative details. - **first_name** (string) - First name. - **last_name** (string) - Last name. - **phone_number** (string) - Phone number. - **email** (string) - Email address. - **shipping_address** (object) - Shipping address details. - **address_line_1** (string) - Address line 1. - **address_line_2** (string) - Address line 2. - **city** (string) - City. - **region** (string) - Region. - **postal_code** (string) - Postal code. - **country_code** (string) - Country code. - **terms** (object) - Repayment terms. - **period** (string) - Payment period (e.g., YEARLY). - **number_of_periods** (integer) - Number of periods. - **start_month** (integer) - Start month. - **invoice_grouping_key** (string) - Invoice grouping key. - **instalments** (object[]) - Array of instalments. - **id** (string) - ID of the instalment. - **reference** (string) - Reference of the instalment. - **invoice_issue_date** (date) - Invoice issue date. - **description** (string) - Description of the instalment. - **repayment_amount** (string) - Repayment amount. - **tax_subtotals** (object[]) - Array of tax subtotals for the instalment. - **tax_rate** (string) - Tax rate. - **taxable_amount** (string) - Taxable amount. - **tax_amount** (string) - Tax amount. #### Response Example ```json { "id": "string", "reference": "string", "description": "string", "total_repayment_amount": "string", "tax_subtotals": [ { "tax_rate": "string", "taxable_amount": "string", "tax_amount": "string" } ], "currency": "DKK", "consent_date": "2024-07-29", "line_items": [ { "name": "string", "description": "string", "product_identifiers": [ { "value": "string", "identifier_type": "EAN" } ], "unit_price_amount": "string", "unit_discount_amount": "string", "tax_rate": "string", "tax_class_name": "string", "quantity": "string", "quantity_unit_name": "string", "line_item_type": "DIGITAL" } ], "account_id": "string", "buyer_representative": { "first_name": "string", "last_name": "string", "phone_number": "string", "email": "user@example.com" }, "shipping_address": { "address_line_1": "string", "address_line_2": "string", "city": "string", "region": "string", "postal_code": "string", "country_code": "string" }, "terms": { "period": "YEARLY", "number_of_periods": 0, "start_month": 0 }, "invoice_grouping_key": "string", "instalments": [ { "id": "string", "reference": "string", "invoice_issue_date": "2024-07-29", "description": "string", "repayment_amount": "string", "tax_subtotals": [ { "tax_rate": "string", "taxable_amount": "string", "tax_amount": "string" } ] } ] } ``` ``` -------------------------------- ### Get specific marketplace merchant Source: https://docs.two.inc/docs/api/marketplace/two-marketplace-api Retrieve detailed information about a specific marketplace merchant by sending a GET request to the /partner/v1/merchant/{merchant_id} endpoint, using the merchant's ID. ```APIDOC ## GET /partner/v1/merchant/{merchant_id} ### Description Retrieves information about a specific marketplace merchant. ### Method GET ### Endpoint /partner/v1/merchant/{merchant_id} ### Path Parameters - **merchant_id** (string) - Required - The unique identifier of the merchant. ### Headers - **X-Api-Key** (string) - Required - Your API key for authentication. - **X-Merchant-Id** (string) - Required - The ID of the merchant whose information is being requested. ### Response #### Success Response (200 OK) - **id** (string) - The unique identifier for the merchant. - **merchant_data** (object) - The information of the merchant. ``` -------------------------------- ### Error Response Example Source: https://docs.two.inc/docs/api/checkout/get-order-payment-link-handler-get This is an example of an error response. It includes fields for error code, details, message, a list of specific errors with location and context, and a trace ID for support. ```json { "error_code": "string", "error_details": "string", "error_message": "string", "error_json": [ { "loc": [ "string", 0 ], "msg": "string", "type": "string", "ctx": "string" } ], "error_trace_id": "string" } ``` -------------------------------- ### POST /plan/preview Source: https://docs.two.inc/docs/api/repay/create-repayment-plan-preview-plan-preview-post Requests a preview of a repayment plan based on key features of a plan including term length and total amount. ```APIDOC ## POST /plan/preview ### Description Requests a preview of a repayment plan based on key features of a plan including term length and total amount. ### Method POST ### Endpoint /plan/preview ### Responses #### Success Response (200) This response indicates a successful request for a repayment plan preview. #### Response Example (No example provided in source) #### Error Response (422) This response indicates a validation error, meaning the request parameters were invalid. #### Response Example (No example provided in source) ``` -------------------------------- ### C# Example for Creating Trade Account User Verification URL Source: https://docs.two.inc/docs/api/trade-account-v3/create-trade-account-user-verication-url-post This snippet demonstrates how to create a user verification URL using HttpClient in C#. It includes setting the request URL, headers (Accept and X-Api-Key), and the JSON request body. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.sandbox.two.inc/trade-account/v3/user/:uid/verification/url"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var content = new StringContent("{\n \"return_url\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Example API Key in Request Header Source: https://docs.two.inc/docs/api/autofill/autofill-api Demonstrates how to include the API key in the request header for authentication. Ensure your API key is kept secure and not shared. ```http GET /something X-Api-Key: secret_test_aabbccddeeff0123456789 ``` -------------------------------- ### Order Recoursed Webhook Payload Example Source: https://docs.two.inc/docs/api/webhooks/order-recoursedreconciliation-recoursed-post This JSON payload represents an example of the order.reconciliation.recoursed.v1 event. It includes details about the recoursed order, invoice, and specific recourse information such as the recourse amount. ```json { "specversion": "1.0", "id": "01FBJ0PYJ7931K0CJ6GMP8N3WG", "type": "order.reconciliation.recoursed.v1", "time": "2023-06-21T12:34:56.123456Z", "source": "https://api.two.inc", "subject": "order/a9f5d2d3-5d6d-4e2a-a4b4-6c7f8a9d0f1e", "twomerchantid":"b6b9d5d1-f6b7-4e15-9703-9c32c6e5c1c2", "data": { "root_order_id": "652a57e2-c2de-437b-96a7-2eeac0a37814", "order_id": "a9f5d2d3-5d6d-4e2a-a4b4-6c7f8a9d0f1e", "invoice_id": "7a5a7b9b-7d9e-4e9e-b9b1-2d7c658e1a4d", "merchant_id": "b6b9d5d1-f6b7-4e15-9703-9c32c6e5c1c2", "billing_period_id": "175bda61-c6f2-4b9d-a429-5f31c83ecc10", "amount": "-101.65", "currency": "GBP", "recourse": { "recourse_id": "4228e51d-45ba-4a7f-a279-0f332bfead9c", "recoursed_at": "2023-06-31T12:34:56.123456", "recourse_amount": "101.65" } } } ``` -------------------------------- ### C# HttpClient Example for Settlement Report Source: https://docs.two.inc/docs/api/checkout/get-merchant-statement-handler-get This C# code snippet shows how to use HttpClient to fetch a settlement report. It includes setting the API key in the request headers and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.sandbox.two.inc/v2/merchant/statement"); request.Headers.Add("X-Api-Key", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Invoice PDF URL (C#) Source: https://docs.two.inc/docs/api/repay/get-invoice-document-url-invoice-invoice-id-pdf-get Use HttpClient to make a GET request to retrieve the invoice PDF URL. Ensure to include the 'X-Api-Key' header for authentication and 'Accept' header for JSON. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.sandbox.two.inc/repay/v1/invoice/:invoice_id/pdf"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("X-Api-Key", ""); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ```