Composable Frontend 2.0 Learn more 

  • Commerce Cloud/
    Account Management/
    Using Account Membership API/
    Create an Account Membership

    Create an Account Membership

    POST Create an Account Membership

    You can only create up to 1000 account memberships in an account.

    https://useast.api.elasticpath.com/v2/accounts/:accountId/account-memberships/
    

    Parameters

    Path parameters

    NameRequiredTypeDescription
    accountIdRequiredstringThe unique identifier of the account that the account is associated with.

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    typeRequiredstringSpecifies the type of the object. Set this value to account_membership.
    account_member_idRequiredstringSpecifies the ID of the account member that the membership is associated with.

    Request Examples

    Curl

    curl -X POST https://useast.api.elasticpath.com/v2/accounts/:accountId/account-memberships// \
        -H "Authorization: Bearer XXXX" \
        -H "Content-Type: application/json" \
        -d $ {
            "data": {
                "type": "account_membership",
                "account_member_id": "486fa6f1-d85a-44a0-abdf-ff0076fffd6c"
              }
        }
    

    JavaScript SDK

    const MoltinGateway = require("@moltin/sdk").gateway;
    const Moltin = MoltinGateway({
        client_id: "X",
        client_secret: "X",
    });
    const accountId = "00000000-0000-1000-8000-000f00000300";
    const accountMemberId = "00000000-0000-1000-8000-000f00000301";
    const accountMembership = {
        type: "account_membership",
        account_member_id: accountMemberId,
    };
    Moltin.AccountMemberships.Create(accountId, accountMembership).then((acc) => {
        // Do something
    });
    

    Response Example

    201 Created

    {
        "data": {
            "id": "9e227208-b592-49c0-8c8f-043b66c634b0",
            "type": "account_membership",
            "meta": {
                "timestamps": {
                    "created_at": "2021-03-10T07:35:38.883Z",
                    "updated_at": "2021-03-10T07:35:38.883Z"
                }
            },
            "relationships": {
                "account_member": {
                    "data": {
                        "id": "486fa6f1-d85a-44a0-abdf-ff0076fffd6c",
                        "type": "account_member"
                    }
                }
            }
        },
        "links": {
            "self": "https://useast.api.elasticpath.com/v2/accounts/b1e8f9ea-7c04-4e16-911c-6898d35731ed/account-memberships/9e227208-b592-49c0-8c8f-043b66c634b0"
        }
    }
    
    Previous
    Get an Account Membership