Invites

$envless->invites->iterate()

Stream pending invitations one at a time

php
/** @return \Generator<int, InviteResource, mixed, void> */
public function iterate(
    ?int $limit = null,
    ?int $offset = null,
    ?string $search = null,
    int|float|null $timeout = null,
): \Generator

Returns a Generator that yields invitations individually and fetches the next page only once the current one is drained. Breaking out of the loop stops the requests, which makes this the cheapest way to find the invite for one email address.

The generator defaults to the maximum page size of 100 and clamps anything larger, so limit only ever makes pages smaller. Revoking or resending while you iterate mutates the underlying set that offsets are counted against, so collect the ids first and act on them after the loop.

Example

php
use Envless\Envless;

$envless = new Envless();

foreach ($envless->invites->iterate() as $invite) {
    if ($invite['email'] === 'dana@example.com') {
        echo "{$invite['id']} {$invite['status']}", PHP_EOL;
        echo $invite['resendCount'], PHP_EOL;

        break;
    }
}

Parameters

ParameterTypeRequiredDescription
$limitintNoPage size per request, capped at 100 and defaulting to 100.
$offsetintNoRow the walk starts at, advancing by the number of items each page returns.
$searchstringNoCase insensitive substring match on the invited email address.
$timeoutint|floatNoSeconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

Generator<int, InviteResource> yielding one invitation per step.

Reads the invites collection. list returns one page as an Envless\Result\Page with items and pagination, listAll collects every page into an array, and iterate returns a Generator that yields one item at a time, fetching the next page only when the loop gets there.

Worth knowing

  • The generator is lazy, so no request is sent until you start consuming it.

Required scopes

members:read

Underlying endpoint

GET /invites

Request and response schema, every error code, and a live playground.

In TypeScript

envless.invites.iterate()

The same method in @goenvless/sdk, with the same request, retries and errors.