# Create plan

Create a new plan with features, rules, default treatment, and optional auto-assignment settings.

Endpoint: POST /resources/plans/v1
Version: 1.0
Security: bearer

## Security:

  - `bearer` (unknown)
    http bearer JWT

## Request fields (application/json):

  - `name` (string, required)
    String that represents the plan name
    Example: Test Plan

  - `defaultTreatment` (string)
    Enum that represents the default treatment
    Enum: "true", "false"

  - `rules` (array)
    Array of rules that represents the set of conditions targeting the plan

  - `rules.description` (string, required)
    String that represents the description of the rule
    Example: This is the first rule

  - `rules.conditionLogic` (string, required)
    Enum that represents the rule conditions logic
    Enum: "and"

  - `rules.conditions` (array, required)
    Array of conditions

  - `rules.conditions.attribute` (string, required)
    String representing an attribute with a subset of condition(s) that is used in code to enact targeting rules
    Example: myCustomAttribute

  - `rules.conditions.attributeType` (string, required)
    Enum that represents the attribute type (`frontegg` or `custom`)
    Enum: "custom", "frontegg"

  - `rules.conditions.negate` (boolean, required)
    Boolean that indicates whether the condition should negate the operation
    Example: false

  - `rules.conditions.op` (string, required)
    Enum that represents the operation applied to the condition
    Enum: "in_list", "starts_with", "ends_with", "contains", "matches", "equal", "greater_than", "greater_than_equal", "lower_than", "lower_than_equal", "between_numeric", "is", "on", "between_date", "on_or_after", "on_or_before"

  - `rules.conditions.value` (object, required)
    Object that contains the condition data according to selected operation, each operation requires different structure (see [documentation](https://docs.frontegg.com/docs/entitlements-backend-sdk#operations-and-corresponding-object-structure))
    Example: {"list":["valueA","valueB"]}

  - `rules.treatment` (string, required)
    String that represents the treatment for this rule
    Enum: "true", "false"

  - `description` (string)
    Feature plan description
    Example: This is a test plan

  - `metadata` (string)
    JSON String
    Example: { "some-key": "some-value" }

  - `defaultTimeLimitation` (number)
    Number that represents the default time limitation in days for auto-assigned plans
    Example: 30

  - `assignOnSignup` (boolean)
    Boolean indicating whether a plan is assigned automatically upon signup
    Example: true

  - `featureKeys` (array)
    Array of feature-keys to be applied on the plan
    Example: ["my-cool-feature"]

## Response 200 fields (application/json):

  - `id` (string, required)
    UUID string that represents the plan ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `vendorId` (string, required)
    UUID string that represents the vendor ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `name` (string, required)
    String that represents the plan name
    Example: Test Plan

  - `defaultTreatment` (string)
    Enum that represents the default treatment
    Enum: "true", "false"

  - `rules` (array)
    Array of rules that represents the set of conditions targeting the plan

  - `rules.description` (string, required)
    String that represents the description of the rule
    Example: This is the first rule

  - `rules.conditionLogic` (string, required)
    Enum that represents the rule conditions logic
    Enum: "and"

  - `rules.conditions` (array, required)
    Array of conditions

  - `rules.conditions.attribute` (string, required)
    String representing an attribute with a subset of condition(s) that is used in code to enact targeting rules
    Example: myCustomAttribute

  - `rules.conditions.attributeType` (string, required)
    Enum that represents the attribute type (`frontegg` or `custom`)
    Enum: "custom", "frontegg"

  - `rules.conditions.negate` (boolean, required)
    Boolean that indicates whether the condition should negate the operation
    Example: false

  - `rules.conditions.op` (string, required)
    Enum that represents the operation applied to the condition
    Enum: "in_list", "starts_with", "ends_with", "contains", "matches", "equal", "greater_than", "greater_than_equal", "lower_than", "lower_than_equal", "between_numeric", "is", "on", "between_date", "on_or_after", "on_or_before"

  - `rules.conditions.value` (object, required)
    Object that contains the condition data according to selected operation, each operation requires different structure (see [documentation](https://docs.frontegg.com/docs/entitlements-backend-sdk#operations-and-corresponding-object-structure))
    Example: {"list":["valueA","valueB"]}

  - `rules.treatment` (string, required)
    String that represents the treatment for this rule
    Enum: "true", "false"

  - `description` (string)
    Feature plan description
    Example: This is a test plan

  - `metadata` (object)
    JSON String
    Example: { "some-key": "some-value" }

  - `defaultTimeLimitation` (number)
    Number that represents the default time limitation in days for auto-assigned plans
    Example: 30

  - `assignOnSignup` (boolean, required)
    Boolean indicating whether a plan is assigned automatically upon signup
    Example: true

  - `createdAt` (string, required)
    Date when plan was created
    Example: 2022-01-01T00:00:00

  - `updatedAt` (string)
    Date when plan was last updated
    Example: 2022-01-01T00:00:00

  - `features` (object)
    List of features linked to a plan

  - `features.id` (string, required)
    UUID string representing the feature ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `features.name` (string, required)
    String representing the feature name
    Example: Test Feature

  - `features.key` (string, required)
    String representing the feature key
    Example: test-feature

  - `features.permissions` (array, required)
    Array of permissions linked to a feature
    Example: ["permission.read","permission.write"]

  - `entitlements` (object)
    List of features linked to a plan

  - `entitlements.id` (string, required)
    UUID string that represents the entitlement ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `entitlements.planId` (string, required)
    UUID string that represents the plan ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `entitlements.tenantId` (string, required)
    UUID string that represents the account (tenant) ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `entitlements.userId` (string)
    UUID string that represents the user ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `entitlements.expirationDate` (string)
    Date of entitlement expiration
    Example: 2022-01-01T12:00:00

  - `entitlements.createdAt` (string, required)
    Date when entitlement was created
    Example: 2022-01-01T12:00:00

  - `entitlements.updatedAt` (string)
    Date when entitlement was last updated
    Example: 2022-01-01T12:00:00

  - `entitlements.plan` (object, required)
    Get the related plan object of the entitlement, in case `withRelations` is set to `true`

  - `entitlements.plan.id` (string, required)
    UUID string that represents the plan ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `entitlements.plan.vendorId` (string, required)
    UUID string that represents the vendor ID
    Example: e6a5012c-cbeb-4c1e-ab80-e5f43efd44e3

  - `entitlements.plan.name` (string, required)
    String that represents the plan name
    Example: Test Plan

  - `entitlements.plan.defaultTimeLimitation` (number)
    Number that represents the default time limitation in days for auto-assigned plans
    Example: 30

  - `entitlements.plan.description` (string)
    Feature plan description
    Example: This is a test plan

  - `entitlements.plan.createdAt` (string, required)
    Date when plan was created
    Example: 2022-01-01T00:00:00

  - `entitlements.plan.updatedAt` (string)
    Date when plan was last updated
    Example: 2022-01-01T00:00:00

