---
title: Create
slug: payments/eol6ekjxrstns-gdy3amb
description: Learn how to use the Create Subscription functionality with this detailed document. Find all the necessary and optional fields required for the request, along with a code snippet to help you initialize the data and make the request using the Breadwinner G
docTags: 
createdAt: 2023-11-29T12:04:56.993Z
---

To create a Subscription in the Square, use the action “CreateSubscription” and pass the Subscription data in the RequestJSON under “subscriptions.”

:::hint{type="info"}
Note: You can only create one record at a time.
:::

Here is an example of creating a Subscription where we are setting every possible field(See[﻿](https://app.archbee.io/docs/-LIHUUnv_7XNQrtzHsKkC/hnjmkN99QxWdEafyYIFSq)﻿ [Subscription - Square](docId\:WkU2GRtLFpcLjd9tmx4eP) for all the available fields). The response will return the response from Square, which includes the Subscription ID (*internalId*) plus the newly created Salesforce Subscription ID (*salesforceId*).

:::CodeblockTabs
```apex
Map<String, Object> subscriptionData = new Map<String, Object>();

// Required fields
subscriptionData.put('processorCustomerId', 'processorCustomerId'); //required
subscriptionData.put('locationId', 'locationId'); //required to Square, if not specified we are sending a request to Square to get the main Square location id.
subscriptionData.put('processorPlanId', 'processorPlanId'); //required

// Optional fields
subscriptionData.put('processorPaymentMethodId', 'processorPaymentMethodId'); // If not specified, the collection method will be considered “send_invoice”.
subscriptionData.put('startDate', 'startDate');

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('subscriptions', new List<Object>{subscriptionData});
String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version','1.0');
reqObj.put('action','CreateSubscription');
reqObj.put('processorId', 'processorId');
reqObj.put('requestJSON',reqJSON);

//  Placing a request to Breadwinner Global API
Map<String,Object> resp = bw_payments.BreadwinnerPaymentsAPI.call(reqObj);
System.debug(resp);
```

```json
 {
    "Action=CreateSubscription",
    "Version=1.0",
    "responseJSON=",
    {
      "subscriptions": [
        {
          "status": "ACTIVE",
          "salesforceId": "salesforceId",
          "salesforceCustomerId": "salesforceCustomerId",
          "salesforceContact": null,
          "salesforceAccount": "salesforceAccount",
          "processorSubscriptionId": "processorSubscriptionId",
          "processorPaymentMethodId": null,
          "processorOrgId": "processorOrgId",
          "processorCustomerId": null,
          "latestInvoice": null,
          "errorMessage": null,
          "currentPeriodStartDate": null,
          "currentPeriodEndDate": null,
          "createdVia": "Breadwinner",
          "createdDateInProcessor": "2023-06-06T08:11:09.000Z",
          "collectionMethod": "Send Invoice",
          "timezone": null,
          "taxPercentage": null,
          "startDate": null,
          "processorPlanId": null,
          "price_override_money": null,
          "locationId": null,
          "canceledDate": null
        }
      ]
    },
    "statusCode=200",
    "timestamp=1686039070310",
    "validRequest=true"
  }
```
:::

