REST API – Memberships Route

Table of Contents

The memberships route allows you to interact with the Restrict Content Pro memberships database to retrieve memberships, add new ones, update existing memberships, and delete memberships.

Note: This endpoint is only available if you have Restrict Content Pro version 3.0 or higher installed.

Get memberships

GET /wp-json/rcp/{version}/memberships/

Required parameters:

  • None.

Optional parameters:

  • id__in (array) – An array of membership IDs. Default empty.
  • id__not_in (array) – An array of membership IDs to exclude from the results. Default empty.
  • customer_id (int) – A customer ID to only return this customer’s memberships. Default empty.
  • customer_id__in (array) – An array of customer IDs to return memberships belonging to these customers. Default empty.
  • customer_id__not_in (array) – An array of customer IDs to exclude their memberships. Default empty.
  • object_id (int) – ID of a membership level to only return memberships of this level. Default empty.
  • object_id__in (array) – An array of membership level IDs to only return memberships of these levels. Default empty.
  • object_id__not_in (array) – An array of membership level IDs to exclude memberships of these levels. Default empty.
  • object_type (string) – An object type to only return memberships of this type. Default empty.
  • object_type__in (array) – An array of object types. Default empty.
  • object_type__not_in (array) – An array of object types to exclude. Default empty.
  • currency (string) – A currency code to only return memberships using this currency. Default empty.
  • created_date_query (array) – Date query clauses to limit memberships by. See WP_Date_Query for supported formats. Default empty.
  • trial_end_date_query (array) – Date query clauses to limit memberships by. See WP_Date_Query for supported formats. Default empty.
  • cancellation_date_date_query (array) – Date query clauses to limit memberships by. See WP_Date_Query for supported formats. Default empty.
  • expiration_date_query (array) – Date query clauses to limit memberships by. See WP_Date_Query for supported formats. Default empty.
  • auto_renew (int) – Filter by auto-renew status (1 for recurring, 0 for not recurring). Default null.
  • status (string) – A status slug, to only return memberships with this status. Supports: pending, active, canceled, expired. Default empty.
  • status__in (array) – Array of status slugs to include. Default empty.
  • status__not_in (array) – Array of status slugs to exclude. Default empty.
  • gateway_customer_id (string) – A gateway customer ID. Default empty.
  • gateway_subscription_id (string) – A gateway subscription ID. Default empty.
  • gateway (string) – A gateway slug. Default empty.
  • subscription_key (string) – A subscription key. Default empty.
  • upgraded_from (int) – ID of a membership. This will return only memberships that were upgraded from this one. Default empty.
  • disabled (int|null) – Whether to show all memberships (null), only enabled memberships (0), or only disabled memberships (1). Default 0.
  • count (bool) – Whether to return a membership count (true) or an array of membership objects (false). Default false.
  • fields (string) – Item fields to return. Accepts any known column name, or empty to return an array of complete membership objects. Default empty.
  • number (int) – Limit the number of results. Default 20.
  • offset (int) – Number of memberships to offset. Default 20.
  • no_found_rows (bool) Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
  • orderby (string) – Accepts `id`, `object_id`, `object_type`, `currency`, `initial_amount`, `recurring_amount`, `created_date`, `trial_end_date`, `cancellation_date`, `expiration_date`, `times_billed`, `maximum_renewals`, `status`, `gateway_customer_id`, `gateway_subscription_id`, and `subscription_key`. Also accepts false, an empty array, or `none` to disable the `ORDER BY` clause. Default `id`.
  • order (string) – How to order results. Accepts `ASC` and `DESC`. Default `DESC`.
  • search (string) – Search term(s) to retrieve matching memberships for. This searches most of the above membership columns. Default empty.
  • update_cache (bool) – Whether to prime the cache for found memberships. Default false.

Get specific membership

GET /wp-json/rcp/{version}/memberships/{membership_id}

Required parameters:

  • id – The membership ID to retrieve. Can be passed in the URL or as part of the body.

Optional parameters:

  • None.

New membership

POST /wp-json/rcp/{version}/memberships/new

Required parameters:

  • customer_id (int) – The ID of the customer this membership is for.
  • object_id (int) – The ID of the membership level this membership is for.

Optional parameters:

  • object_type (string) – Optional. The type of object. Default is `membership`.
  • currency (string) – Optional. Currency used for the membership. Default is the currency specified in Restrict > Settings > Payments.
  • initial_amount (string) – Optional. Amount charged on initial registration. Default is `0.00`.
  • recurring_amount (string) – Optional. Amount charged for renewals. Default is `0.00`.
  • created_date (string) – Optional. Date the membership was created in MySQL format. Default is the current date and time.
  • trial_end_date (string) – Optional. Date the integrated free trial ends. If omitted, this will be set automatically based on the customer’s free trial allowance and whether or not the associated object ID has a built-in trial.
  • expiration_date (string) – Optional. Date the membership expires or renews, in MySQL format. Use `none` if the membership never expires. If omitted, this is auto-calculated based on the associated object ID.
  • auto_renew (bool) – Optional. TRUE if this membership has auto-renew enabled, FALSE if it does not. Default `false`.
  • times_billed (int) – Optional. Number of times this membership has been billed for so far. Default `0`.
  • status (string) – Optional. Status of the membership. Accepts: pending, active, canceled, expired. Default `pending`.
  • gateway_customer_id (string) – Optional. Gateway customer ID. Default empty.
  • gateway_subscription_id (string) – Optional. Gateway subscription ID. Default empty.
  • gateway (string) – Optional. Slug of the gateway. Default empty.
  • signup_method (string) – Optional. Signup method. Accepts: live, manual, imported. Default `live`.
  • subscription_key (string) – Optional. Unique subscription key for this membership. Default empty.
  • notes (string) – Optional. Notes for the membership. Setting this manually here is not recommended. Default empty.
  • upgraded_from (int) – Optional. ID of a membership this one was upgraded from. Default empty.
  • disabled (int) – Optional. Whether this membership is disabled (1) or enabled (0). Default `0`.

Update membership

POST /wp-json/rcp/{version}/memberships/update/{membership_id}

Required parameters:

  • id (int) – The ID of the membership to update. Can be passed in the URL or as part of the body.

Optional parameters:

  • customer_id (int) – The ID of the customer this membership is for.
  • object_id (int) – The ID of the membership level this membership is for.
  • object_type (string) – Optional. The type of object. Default is `membership`.
  • currency (string) – Optional. Currency used for the membership. Default is the currency specified in Restrict > Settings > Payments.
  • initial_amount (string) – Optional. Amount charged on initial registration. Default is `0.00`.
  • recurring_amount (string) – Optional. Amount charged for renewals. Default is `0.00`.
  • created_date (string) – Optional. Date the membership was created in MySQL format. Default is the current date and time.
  • trial_end_date (string) – Optional. Date the integrated free trial ends. If omitted, this will be set automatically based on the customer’s free trial allowance and whether or not the associated object ID has a built-in trial.
  • expiration_date (string) – Optional. Date the membership expires or renews, in MySQL format. Use `none` if the membership never expires.
  • auto_renew (bool) – Optional. TRUE if this membership has auto-renew enabled, FALSE if it does not. Default `false`.
  • times_billed (int) – Optional. Number of times this membership has been billed for so far. Default `0`.
  • status (string) – Optional. Status of the membership. Accepts: pending, active, canceled, expired. Default `pending`.
  • gateway_customer_id (string) – Optional. Gateway customer ID. Default empty.
  • gateway_subscription_id (string) – Optional. Gateway subscription ID. Default empty.
  • gateway (string) – Optional. Slug of the gateway. Default empty.
  • signup_method (string) – Optional. Signup method. Accepts: live, manual, imported. Default `live`.
  • subscription_key (string) – Optional. Unique subscription key for this membership. Default empty.
  • notes (string) – Optional. Notes for the membership. Setting this manually here is not recommended. Default empty.
  • upgraded_from (int) – Optional. ID of a membership this one was upgraded from. Default empty.
  • disabled (int) – Optional. Whether this membership is disabled (1) or enabled (0). Default `0`.

Renew membership

This endpoint requires RCP REST API version 1.2 or higher.

POST /wp-json/rcp/{version}/memberships/{membership_id}/renew

Extends the membership for another billing period.

Required parameters:

  • id (int) – The ID of the membership to renew. Can be passed in the URL or as part of the body.

Optional parameters:

  • recurring (bool) – Whether or not the membership is recurring. Default is current recurring status.
  • status (string) – New membership status. Default is active.
  • expiration (string) – New membership expiration date. Default is to auto calculate based on the current membership level billing cycle.

Cancel membership

This endpoint requires RCP REST API version 1.2 or higher.

POST /wp-json/rcp/{version}/memberships/{membership_id}/cancel

Sets the membership status to “canceled” and, if applicable, cancels the recurring subscription at the payment gateway.

Required parameters:

  • id (int) – The ID of the membership to renew. Can be passed in the URL or as part of the body.

Delete membership

DELETE /wp-json/rcp/{version}/memberships/delete

Required parameters:

  • id (int) – The ID of the membership to delete

Optional parameters:

  • None.

Have more questions? Submit a request

Have more questions?

Submit a request