> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetSubscriptionContractDraftability

# Package: subscriptions

# Namespace: DraftSubscriptionContractsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/subscriptions/draft-subscription-contracts/get-subscription-contract-draftability.md

## Permission Scopes:
Read draft subscription contracts: SCOPE.ECOM.DRAFT-SUBSCRIPTION-CONTRACT-READ

## Introduction

Retrieves whether a subscription contract can be edited with a draft subscription contract.

Call this method before [Create Draft Subscription Contract](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/subscriptions/draft-subscription-contracts/create-draft-subscription-contract.md),
for example to decide whether to show an edit option in your UI.
When the subscription contract can't be edited, `nonDraftableReasons` explains why.
When a site member calls this method for a subscription contract they didn't buy,
the only reason returned is `NOT_SUBSCRIPTION_CONTRACT_BUYER`.

The response also returns `currentCycleNumber`. Use it to set `target.contractTarget.nextCycleNumber`
when you create the draft subscription contract.

---

## REST API

### Schema

```
 Method: getSubscriptionContractDraftability
 Description: Retrieves whether a subscription contract can be edited with a draft subscription contract.  Call this method before [Create Draft Subscription Contract](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/subscriptions/draft-subscription-contracts/create-draft-subscription-contract.md), for example to decide whether to show an edit option in your UI. When the subscription contract can't be edited, `nonDraftableReasons` explains why. When a site member calls this method for a subscription contract they didn't buy, the only reason returned is `NOT_SUBSCRIPTION_CONTRACT_BUYER`.  The response also returns `currentCycleNumber`. Use it to set `target.contractTarget.nextCycleNumber` when you create the draft subscription contract.
 URL: https://www.wixapis.com/ecom/v1/draft-subscription-contracts/draftability
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  subscriptionContractId
 Method parameters: 
   query param name: subscriptionContractId | type: subscriptionContractId | description: Subscription contract GUID. | required: true | validation: format GUID
 Return type: GetSubscriptionContractDraftabilityResponse
  - name: draftable | type: boolean | description: Whether you can create a draft subscription contract for the subscription contract.  
  - name: nonDraftableReasons | type: array<NonDraftableReason> | description: Reasons why you can't create a draft subscription contract.  Empty when `draftable` is `true`.  | validation: minItems 0, maxItems 12
     - ONE-OF: 
        - name: draftAlreadyExistsForAnotherOwner | type: DraftAlreadyExistsForAnotherOwnerReasonDetails | description: Details about the existing draft subscription contract. Returned when `reason` is `DRAFT_ALREADY_EXISTS_FOR_ANOTHER_OWNER`.  
           - name: draftSubscriptionContractId | type: string | description: GUID of the existing draft subscription contract.  | validation: format GUID
           - name: createdBy | type: CreatedBy | description: Identity that created the existing draft subscription contract.  When a site member calls the method, only `identityType` is returned.  
              - ONE-OF: 
                 - name: userId | type: string | description: User GUID. Returned when a Wix user created the draft subscription contract.  | validation: format GUID
                 - name: appId | type: string | description: App GUID. Returned when an app created the draft subscription contract.  | validation: format GUID
                 - name: memberId | type: string | description: Member GUID. Returned when a site member created the draft subscription contract.  | validation: format GUID
              - name: identityType | type: IdentityType | description: Type of identity that created the draft subscription contract.  
                     - enum:
                     -     USER: A Wix user.
                     -     APP: An app.
                     -     MEMBER: A site member.
     - name: reason | type: Reason | description: Reason code.  
         - enum:
         -     SUBSCRIPTION_CONTRACT_NOT_FOUND: Couldn't find the subscription contract.
         -     UNSUPPORTED_CATALOG: The subscription contract has items from a catalog that doesn't support editing.
         -     UNSUPPORTED_CHANNEL_TYPE: The subscription contract was created through a sales channel that doesn't support editing.
         -     CURRENCY_MISMATCH: The subscription contract's currency is different from the site's currency.
         -     WEIGHT_UNIT_MISMATCH: The subscription contract's weight unit is different from the site's weight unit.
         -     DRAFT_ALREADY_EXISTS_FOR_ANOTHER_OWNER: Another identity already has a draft subscription contract with the `DRAFT` status for this subscription contract.
         -     LAST_CYCLE: The subscription is in its last billing cycle, so there are no future billing cycles to change.
         -     GRACE_PERIOD: The subscription is in a grace period after a failed payment.
         -     UNSUPPORTED_STATUS: The subscription's status doesn't allow editing.
         -     SUBSCRIPTION_NOT_EDITABLE: The subscription can't be edited, for a reason that the other values don't cover.
         -     MULTIPLE_CATALOGS: The subscription contract has items from more than 1 catalog.
         -     NOT_SUBSCRIPTION_CONTRACT_BUYER: The calling site member isn't the buyer of the subscription contract.
  - name: currentCycleNumber | type: integer | description: Number of the billing cycle the subscription is in now.  To create a draft subscription contract, set `target.contractTarget.nextCycleNumber` to `currentCycleNumber` + 1.  Not returned when the subscription contract wasn't found, or when the calling site member isn't its buyer.  | validation: format int32


```

### Examples

### Check whether a subscription contract can be edited
Checks that a subscription contract is eligible for a draft. The contract is draftable and is in its first billing cycle.

```curl
curl -X GET \
'https://www.wixapis.com/ecom/v1/draft-subscription-contracts/draftability?subscriptionContractId=9ac67bb1-6bd5-4205-8a1c-e2d4ca6745c1' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.draftSubscriptionContracts.getSubscriptionContractDraftability(subscriptionContractId)
 Description: Retrieves whether a subscription contract can be edited with a draft subscription contract.  Call this method before [Create Draft Subscription Contract](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/subscriptions/draft-subscription-contracts/create-draft-subscription-contract.md), for example to decide whether to show an edit option in your UI. When the subscription contract can't be edited, `nonDraftableReasons` explains why. When a site member calls this method for a subscription contract they didn't buy, the only reason returned is `NOT_SUBSCRIPTION_CONTRACT_BUYER`.  The response also returns `currentCycleNumber`. Use it to set `target.contractTarget.nextCycleNumber` when you create the draft subscription contract.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  subscriptionContractId
 Method parameters: 
   param name: subscriptionContractId | type: string | description: Subscription contract GUID. | required: true | validation: format GUID
 Return type: PROMISE<GetSubscriptionContractDraftabilityResponse>
  - name: draftable | type: boolean | description: Whether you can create a draft subscription contract for the subscription contract.  
  - name: nonDraftableReasons | type: array<NonDraftableReason> | description: Reasons why you can't create a draft subscription contract.  Empty when `draftable` is `true`.  | validation: minItems 0, maxItems 12
     - ONE-OF: 
        - name: draftAlreadyExistsForAnotherOwner | type: DraftAlreadyExistsForAnotherOwnerReasonDetails | description: Details about the existing draft subscription contract. Returned when `reason` is `DRAFT_ALREADY_EXISTS_FOR_ANOTHER_OWNER`.  
           - name: draftSubscriptionContractId | type: string | description: GUID of the existing draft subscription contract.  | validation: format GUID
           - name: createdBy | type: CreatedBy | description: Identity that created the existing draft subscription contract.  When a site member calls the method, only `identityType` is returned.  
              - ONE-OF: 
                 - name: userId | type: string | description: User GUID. Returned when a Wix user created the draft subscription contract.  | validation: format GUID
                 - name: appId | type: string | description: App GUID. Returned when an app created the draft subscription contract.  | validation: format GUID
                 - name: memberId | type: string | description: Member GUID. Returned when a site member created the draft subscription contract.  | validation: format GUID
              - name: identityType | type: IdentityType | description: Type of identity that created the draft subscription contract.  
                     - enum:
                     -     USER: A Wix user.
                     -     APP: An app.
                     -     MEMBER: A site member.
     - name: reason | type: Reason | description: Reason code.  
         - enum:
         -     SUBSCRIPTION_CONTRACT_NOT_FOUND: Couldn't find the subscription contract.
         -     UNSUPPORTED_CATALOG: The subscription contract has items from a catalog that doesn't support editing.
         -     UNSUPPORTED_CHANNEL_TYPE: The subscription contract was created through a sales channel that doesn't support editing.
         -     CURRENCY_MISMATCH: The subscription contract's currency is different from the site's currency.
         -     WEIGHT_UNIT_MISMATCH: The subscription contract's weight unit is different from the site's weight unit.
         -     DRAFT_ALREADY_EXISTS_FOR_ANOTHER_OWNER: Another identity already has a draft subscription contract with the `DRAFT` status for this subscription contract.
         -     LAST_CYCLE: The subscription is in its last billing cycle, so there are no future billing cycles to change.
         -     GRACE_PERIOD: The subscription is in a grace period after a failed payment.
         -     UNSUPPORTED_STATUS: The subscription's status doesn't allow editing.
         -     SUBSCRIPTION_NOT_EDITABLE: The subscription can't be edited, for a reason that the other values don't cover.
         -     MULTIPLE_CATALOGS: The subscription contract has items from more than 1 catalog.
         -     NOT_SUBSCRIPTION_CONTRACT_BUYER: The calling site member isn't the buyer of the subscription contract.
  - name: currentCycleNumber | type: integer | description: Number of the billing cycle the subscription is in now.  To create a draft subscription contract, set `target.contractTarget.nextCycleNumber` to `currentCycleNumber` + 1.  Not returned when the subscription contract wasn't found, or when the calling site member isn't its buyer.  | validation: format int32


```

### Examples

### Check whether a subscription contract can be edited
Checks that a subscription contract is eligible for a draft. The contract is draftable and is in its first billing cycle.

```javascript
import { draftSubscriptionContracts } from "@wix/ecom";

async function getSubscriptionContractDraftability() {
  const response = await draftSubscriptionContracts.getSubscriptionContractDraftability(
    "9ac67bb1-6bd5-4205-8a1c-e2d4ca6745c1",
  );
}

/* Promise resolves to:
 * {
 *   "draftable": true,
 *   "currentCycleNumber": 1
 * }
 */

```

### getSubscriptionContractDraftability (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { draftSubscriptionContracts } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { draftSubscriptionContracts },
  // Include the auth strategy and host as relevant
});


async function getSubscriptionContractDraftability(subscriptionContractId) {
  const response = await myWixClient.draftSubscriptionContracts.getSubscriptionContractDraftability(subscriptionContractId);
};
```

---