> 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

# GenerateAccountInviteLinks

# Package: eligibility

# Namespace: OrganizationService

# Method link: https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/generate-account-invite-links.md

## Permission Scopes:
Manage Channels Account Codes: SCOPE.CHANNELS.MANAGE_ACCOUNT_KEYS

## Introduction

Generates sign-in invite links that link your users' Wix accounts to your account.


Each invite link is a full sign-in URL that contains a one-time-use account code. For example,
`https://users.wix.com/signin?organizationId=<accountId>&organizationInviteCode=<code>`.
When a user opens the link and signs up or logs in to Wix, their account is linked to
your account as a sub-account. Links in the same batch differ only by the value of the
`organizationInviteCode` query parameter.

Your account must be set up by Wix as a Channel organization account. Otherwise, the call
fails with `ORGANIZATION_NOT_ELIGIBLE`.

An account can have up to 5,000,000 active account codes, meaning codes that haven't been
redeemed and haven't expired. If generating the batch would exceed this limit, the call
fails and no account codes are created.

To delete account codes you no longer want to be redeemable, call
[Delete Account Code](https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/delete-account-code.md)
or [Bulk Delete Account Codes](https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/bulk-delete-account-codes.md).

The account the invite links are issued for is always the calling channel's own
account, taken from the identity of the API key used to make the call. It's never
taken from a value passed in the request.

---

## REST API

### Schema

```
 Method: generateAccountInviteLinks
 Description: Generates sign-in invite links that link your users' Wix accounts to your account.   Each invite link is a full sign-in URL that contains a one-time-use account code. For example, `https://users.wix.com/signin?organizationId=<accountId>&organizationInviteCode=<code>`. When a user opens the link and signs up or logs in to Wix, their account is linked to your account as a sub-account. Links in the same batch differ only by the value of the `organizationInviteCode` query parameter.  Your account must be set up by Wix as a Channel organization account. Otherwise, the call fails with `ORGANIZATION_NOT_ELIGIBLE`.  An account can have up to 5,000,000 active account codes, meaning codes that haven't been redeemed and haven't expired. If generating the batch would exceed this limit, the call fails and no account codes are created.  To delete account codes you no longer want to be redeemable, call [Delete Account Code](https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/delete-account-code.md) or [Bulk Delete Account Codes](https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/bulk-delete-account-codes.md).  The account the invite links are issued for is always the calling channel's own account, taken from the identity of the API key used to make the call. It's never taken from a value passed in the request.
 URL: https://www.wixapis.com/channels-eligibility/v1/channels-eligibility/account-codes/generate-invite-links
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  count
 Method parameters: 
   param name: count | type: count | description: Number of invite links to generate. | required: true | validation: minimum 1, maximum 5000
   param name: expirationDurationInSeconds | type: expirationDurationInSeconds | description: Number of seconds the generated account codes stay redeemable. For example, `2592000` for 30 days.  Default: `15724800` (182 days)  | validation: minimum 60, maximum 31536000, format int32
 Return type: GenerateAccountInviteLinksResponse
  - name: inviteLinks | type: array<string> | description: Generated sign-in invite links, one for each account code that was created. For example, `https://users.wix.com/signin?organizationId=<accountId>&organizationInviteCode=<code>`. Send each link to a user without modifying it.  May contain fewer links than the requested `count` if some account codes couldn't be created. If none of the account codes could be created, the call fails.  | validation: maxItems 5000, maxLength 2200
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata. `totalSuccesses` equals the number of links in `inviteLinks`, and `totalFailures` is the number of requested account codes that couldn't be created.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  | validation: minimum 0
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  | validation: minimum 0
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  | validation: minimum 0

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: MISSING_IDENTITY | Description: Couldn't identify the calling account. Call this method with an account-level API key.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ACCOUNT_ACTIVE_CODE_LIMIT_EXCEEDED | Description: Generating this batch would exceed the account's limit of 5,000,000 active account codes. Delete unredeemed codes or wait for codes to expire, or specify a smaller `count`.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORGANIZATION_NOT_ELIGIBLE | Description: Your account isn't set up by Wix as a Channel organization account. Contact your Wix partner manager to get set up.


```

### Examples

### Generate account invite links
```curl
curl -X POST \
'https://www.wixapis.com/channels-eligibility/v1/channels-eligibility/account-codes/generate-invite-links' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "count": 2,
  "expirationDurationInSeconds": 604800
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.channels.accountCodes.generateAccountInviteLinks(count, options)
 Description: Generates sign-in invite links that link your users' Wix accounts to your account.   Each invite link is a full sign-in URL that contains a one-time-use account code. For example, `https://users.wix.com/signin?organizationId=<accountId>&organizationInviteCode=<code>`. When a user opens the link and signs up or logs in to Wix, their account is linked to your account as a sub-account. Links in the same batch differ only by the value of the `organizationInviteCode` query parameter.  Your account must be set up by Wix as a Channel organization account. Otherwise, the call fails with `ORGANIZATION_NOT_ELIGIBLE`.  An account can have up to 5,000,000 active account codes, meaning codes that haven't been redeemed and haven't expired. If generating the batch would exceed this limit, the call fails and no account codes are created.  To delete account codes you no longer want to be redeemable, call [Delete Account Code](https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/delete-account-code.md) or [Bulk Delete Account Codes](https://dev.wix.com/docs/api-reference/account-level/channels/eligibility/account-code-v1/bulk-delete-account-codes.md).  The account the invite links are issued for is always the calling channel's own account, taken from the identity of the API key used to make the call. It's never taken from a value passed in the request.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  count
 Method parameters: 
   param name: count | type: integer | description: Number of invite links to generate. | required: true | validation: minimum 1, maximum 5000
   param name: options | type: GenerateAccountInviteLinksOptions  none  
        - name: expirationDurationInSeconds | type: integer | description: Number of seconds the generated account codes stay redeemable. For example, `2592000` for 30 days.  Default: `15724800` (182 days)  | validation: minimum 60, maximum 31536000, format int32
 Return type: PROMISE<GenerateAccountInviteLinksResponse>
  - name: inviteLinks | type: array<string> | description: Generated sign-in invite links, one for each account code that was created. For example, `https://users.wix.com/signin?organizationId=<accountId>&organizationInviteCode=<code>`. Send each link to a user without modifying it.  May contain fewer links than the requested `count` if some account codes couldn't be created. If none of the account codes could be created, the call fails.  | validation: maxItems 5000, maxLength 2200
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata. `totalSuccesses` equals the number of links in `inviteLinks`, and `totalFailures` is the number of requested account codes that couldn't be created.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  | validation: minimum 0
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  | validation: minimum 0
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  | validation: minimum 0

 Possible Errors:
   HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: MISSING_IDENTITY | Description: Couldn't identify the calling account. Call this method with an account-level API key.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ACCOUNT_ACTIVE_CODE_LIMIT_EXCEEDED | Description: Generating this batch would exceed the account's limit of 5,000,000 active account codes. Delete unredeemed codes or wait for codes to expire, or specify a smaller `count`.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ORGANIZATION_NOT_ELIGIBLE | Description: Your account isn't set up by Wix as a Channel organization account. Contact your Wix partner manager to get set up.


```

### Examples

### Generate account invite links
```javascript
import { accountCodes } from "@wix/channels";

async function generateAccountInviteLinks() {
  const response = await accountCodes.generateAccountInviteLinks(
    2,
    { expirationDurationInSeconds: 604800 },
  );
}

/* Promise resolves to:
 * {
 *   "inviteLinks": [
 *     "https://users.wix.com/signin?organizationId=6b1f9e6a-3c2d-4f0e-9a1b-7e5d2c8f4a6b&organizationInviteCode=eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..q3Xk9mPzT2vL8nRw4bYc1A.Hf7sK2mQ9xV4pL6tN1rW8eZ3uB5yC0dJ.Ra4Tn8Wq2Ls6Xv1Kp9Bm3g",
 *     "https://users.wix.com/signin?organizationId=6b1f9e6a-3c2d-4f0e-9a1b-7e5d2c8f4a6b&organizationInviteCode=eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..Lr7Tb2WnX5cQ8mPa1vKs3D.Mc2vR8tY5nK1wQ7pL4xZ9bH6sE3jF0gA.Uy6Pk1Rz9Nf4Wc2Lt7Hq5e"
 *   ],
 *   "bulkActionMetadata": {
 *     "totalSuccesses": 2,
 *     "totalFailures": 0,
 *     "undetailedFailures": 0
 *   }
 * }
 */

```

### generateAccountInviteLinks (self-managed)
Self-managed 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 { accountCodes } from '@wix/channels';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function generateAccountInviteLinks(count,options) {
  const response = await myWixClient.accountCodes.generateAccountInviteLinks(count,options);
};
```

---