Download the PHP package loops-so/loops without Composer

On this page you can find all versions of the php package loops-so/loops. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package loops

Loops PHP Package

Packagist Total Downloads

Introduction

This is the official PHP package for Loops, an email platform for modern software companies.

Installation

Install the Loops package using Composer:

Requires PHP 8.1.

Usage

You will need a Loops API key to use the package.

In your Loops account, go to the API Settings page and click Generate key.

Copy this key and save it in your application code (for example, in an environment variable).

See the API documentation to learn more about rate limiting and error handling.

To use the package, first initialise the client with your API key, then you can call one of the methods.

API rate limits can be handled with the included RateLimitExceededError exception.

Handling rate limits

You can use the check for rate limit issues with your requests.

You can access details about the rate limits from the getLimit and getRemaining functions.

Default contact properties

Each contact in Loops has a set of default properties. These will always be returned in API results.

Custom contact properties

You can use custom contact properties in API calls. Please make sure to add custom properties in your Loops account before using them with the SDK.

Methods


apiKey->test()

Test if your API key is valid.

API Reference

Parameters

None

Example

Response

This method will return a success or error message:


contacts->create()

Create a new contact.

API Reference

Parameters

Name Type Required Notes
$email string Yes If a contact already exists with this email address, an APIError will be thrown.
$properties array No An array containing default and any custom properties for your contact.
Please add custom properties in your Loops account before using them with the SDK.
Values can be of type string, number, null (to reset a value), boolean or date (see allowed date formats).
$mailing_lists array No An array of mailing list IDs and boolean subscription statuses.

Examples

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


contacts->update()

Update a contact.

Note: To update a contact's email address, the contact requires a $user_id value. Then you can make a request with their $user_id and an updated email address.

API Reference

Parameters

Name Type Required Notes
$email string No The email address of the contact to update. If there is no contact with this email address, a new contact will be created using the email and properties in this request. Required if $user_id is not present.
$user_id string No The contact's unique user ID. If you use $user_id without $email, this value must have already been added to your contact in Loops. Required if $email is not present.
$properties array No An array containing default and any custom properties for your contact.
Please add custom properties in your Loops account before using them with the SDK.
Values can be of type string, number, null (to reset a value), boolean or date (see allowed date formats).
$mailing_lists array No An array of mailing list IDs and boolean subscription statuses.

Example

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


contacts->find()

Find a contact.

API Reference

Parameters

You must use one parameter in the request.

Name Type Required Notes
$email string No
$user_id string No

Examples

Response

This method will return a list containing a single contact object, which will include all default properties and any custom properties.

If no contact is found, an empty list will be returned.


contacts->delete()

Delete a contact.

API Reference

Parameters

You must use one parameter in the request.

Name Type Required Notes
$email string No
$user_id string No

Example

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


contacts->checkSuppression()

Check if a contact is currently suppressed.

API Reference

Parameters

You must use one parameter in the request.

Name Type Required Notes
$email string No
$user_id string No

Example

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


contacts->removeSuppression()

Remove suppression for a contact.

API Reference

Parameters

You must use one parameter in the request.

Name Type Required Notes
$email string No
$user_id string No

Example

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


contactProperties->create()

Create a new contact property.

API Reference

Parameters

Name Type Required Notes
$name string Yes The name of the property. Should be in camelCase, like planName or favouriteColor.
$type string Yes The property's value type.
Can be one of string, number, boolean or date.

Examples

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


contactProperties->list()

Get a list of your account's contact properties.

API Reference

Parameters

Name Type Required Notes
$list string No Use "custom" to retrieve only your account's custom properties.

Example

Response

This method will return a list of contact property objects containing key, label and type attributes.


mailingLists->list()

Get a list of your account's mailing lists. Read more about mailing lists

API Reference

Parameters

None

Example

Response

This method will return a list of mailing list objects containing id, name, description and isPublic attributes.

If your account has no mailing lists, an empty list will be returned.


events->send()

Send an event to trigger an email in Loops. Read more about events

API Reference

Parameters

Name Type Required Notes
$event_name string Yes
$email string No The contact's email address. Required if $user_id is not present.
$user_id string No The contact's unique user ID. If you use $user_id without $email, this value must have already been added to your contact in Loops. Required if $email is not present.
$contact_properties array No An array containing contact properties, which will be updated or added to the contact when the event is received.
Please add custom properties in your Loops account before using them with the SDK.
Values can be of type string, number, null (to reset a value), boolean or date (see allowed date formats).
$event_properties array No An array containing event properties, which will be made available in emails that are triggered by this event.
Values can be of type string, number, boolean or date (see allowed date formats).
$mailing_lists array No An array of mailing list IDs and boolean subscription statuses.
$headers array No Additional headers to send with the request.

Examples

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.


transactional->send()

Send a transactional email to a contact. Learn about sending transactional email

API Reference

Parameters

Name Type Required Notes
$transactional_id string Yes The ID of the transactional email to send.
$email string Yes The email address of the recipient.
$add_to_audience boolean No If true, a contact will be created in your audience using the $email value (if a matching contact doesn’t already exist).
$data_variables array No An array containing data as defined by the data variables added to the transactional email template.
Values can be of type string or number.
$attachments array[] No A list of attachments objects.
Please note: Attachments need to be enabled on your account before using them with the API. Read more
$attachments[]["filename"] string No The name of the file, shown in email clients.
$attachments[]["contentType"] string No The MIME type of the file.
$attachments[]["data"] string No The base64-encoded content of the file.
$headers array No Additional headers to send with the request.

Examples

Response

Error handling is done through the APIError class, which provides getStatusCode() and getJson() methods for retrieving the API's error response details. For implementation examples, see the Usage section.

If there is a problem with the request, a descriptive error message will be returned:


transactional->list()

Get a paginated list of transactional emails, most recently created first.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example

Response


transactional->create()

Create a new transactional email. An empty draft email message is created automatically.

API Reference

Parameters

Name Type Required Notes
$name string Yes The name of the transactional email.
$transactional_group_id string No The ID of the group to add this transactional email to. Defaults to the team's default group when omitted.

Example

Response


transactional->get()

Get a single transactional email by ID.

API Reference

Parameters

Name Type Required Notes
$transactional_id string Yes The ID of the transactional email.

Example


transactional->update()

Update a transactional email.

At least one field alongside transactional_id must be provided.

API Reference

Parameters

Name Type Required Notes
$transactional_id string Yes The ID of the transactional email.
$name string No The updated name.
$transactional_group_id string No The ID of the group to move this transactional email to.

Example


transactional->ensureDraft()

Ensure a transactional email has a draft email message. If a draft already exists it is returned unchanged; otherwise a new empty draft is created.

API Reference

Parameters

Name Type Required Notes
$transactional_id string Yes The ID of the transactional email.

Example


transactional->publish()

Publish the transactional email's current draft email message.

API Reference

Parameters

Name Type Required Notes
$transactional_id string Yes The ID of the transactional email.

Example


uploads->upload()

Upload an image asset for use in LMX email content. The returned finalUrl can be used in an <Image> tag in your LMX content.

API Reference

Parameters

Name Type Required Notes
$path string Yes Path to an image file. Supported types: JPEG, PNG, GIF, and WebP. Maximum file size is 4,000,000 bytes (4 MB).

Example

Response


dedicatedSendingIps->list()

Get a list of Loops' dedicated sending IP addresses.

API Reference

Parameters

None

Example

Response


themes->list()

List email themes.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


themes->get()

Get a single email theme by ID.

API Reference

Parameters

Name Type Required Notes
$theme_id string Yes The ID of the theme.

Example


themes->create()

Create an email theme.

API Reference

Parameters

Name Type Required Notes
$name string Yes The theme name.
$styles array No Style attributes matching LMX <Style /> attribute names.

Example


themes->update()

Update a theme's name and/or styles. Style changes cascade to emails using the theme.

At least one of $name or $styles must be provided.

API Reference

Parameters

Name Type Required Notes
$theme_id string Yes The ID of the theme.
$name string No The updated theme name.
$styles array No Updated style attributes.

Example


components->list()

List email components.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


components->get()

Get a single email component by ID.

API Reference

Parameters

Name Type Required Notes
$component_id string Yes The ID of the component.

Example


components->create()

Create an email component from an LMX body.

API Reference

Parameters

Name Type Required Notes
$name string Yes The component name.
$lmx string Yes The component body as LMX.

Example


components->update()

Update a component's name and/or LMX body. Body changes cascade to emails using the component.

At least one of $name or $lmx must be provided.

API Reference

Parameters

Name Type Required Notes
$component_id string Yes The ID of the component.
$name string No The updated component name.
$lmx string No The updated LMX body.

Example


campaigns->list()

List campaigns.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


campaigns->create()

Create a new draft campaign.

API Reference

Parameters

Name Type Required Notes
$name string Yes The campaign name.
$campaign_group_id string No The ID of the group to add this campaign to.
$mailing_list_id string No The ID of the mailing list to send to.
$audience_segment_id string No The ID of an audience segment. Setting this without also providing audience_filter clears any existing audience_filter. If both are provided, the filter is applied on top of the segment's filter.
$audience_filter array No A tree of audience conditions. See the API reference for the filter schema. Setting this without also providing audience_segment_id clears any existing audience_segment_id.
$scheduling array No When the campaign should send. Use ['method' => 'now'] or ['method' => 'schedule', 'timestamp' => '...'].

Example

Response


campaigns->get()

Get a single campaign by ID.

API Reference

Parameters

Name Type Required Notes
$campaign_id string Yes The ID of the campaign.

Example


campaigns->update()

Update a draft campaign's name, group, audience, or scheduling.

At least one field must be provided.

API Reference

Parameters

Name Type Required Notes
$campaign_id string Yes The ID of the campaign.
$name string No The updated name.
$campaign_group_id string No The ID of the group to move this campaign to.
$scheduling array No When the campaign should send. Use ['method' => 'now'] or ['method' => 'schedule', 'timestamp' => '...'].
$mailing_list_id string No The ID of the mailing list to send to. Pass null to clear.
$audience_segment_id string No The ID of an audience segment. Setting this without also providing audience_filter clears any existing audience_filter. If both are provided, the filter is applied on top of the segment's filter. Pass null to clear.
$audience_filter array No A tree of audience conditions. See the API reference for the filter schema. Setting this without also providing audience_segment_id clears any existing audience_segment_id. Pass null to clear.

Example


campaignGroups->list()

List campaign groups.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


campaignGroups->create()

Create a campaign group.

API Reference

Parameters

Name Type Required Notes
$name string Yes Cannot be the reserved name "Unsorted".
$description string No An optional description for the group.

Example


campaignGroups->get()

Get a campaign group by ID.

API Reference

Parameters

Name Type Required Notes
$campaign_group_id string Yes The ID of the campaign group.

Example


campaignGroups->update()

Update a campaign group's name or description.

At least one field alongside campaign_group_id must be provided.

API Reference

Parameters

Name Type Required Notes
$campaign_group_id string Yes The ID of the campaign group.
$name string No Cannot be the reserved name "Unsorted".
$description string No

Example


audienceSegments->list()

List audience segments.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


audienceSegments->create()

Create an audience segment.

API Reference

Parameters

Name Type Required Notes
$name string Yes The segment name. Must be unique within the team.
$filter array Yes A tree of audience conditions with match and conditions.
$description string No An optional description of the audience segment.

Example


audienceSegments->get()

Get an audience segment by ID.

API Reference

Parameters

Name Type Required Notes
$audience_segment_id string Yes The ID of the audience segment.

Example


workflows->list()

List workflows.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


workflows->create()

Create a draft workflow with a blank trigger and exit node.

API Reference

Parameters

Name Type Required Notes
$name string Yes The workflow name.
$description string No The workflow description.
$mailing_list_id string No The mailing list the workflow sends to.

Example

Response


workflows->get()

Get a simplified workflow graph.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.

Example


workflows->update()

Update a workflow's display properties.

At least one of $name or $description must be provided. To change the mailing list, use workflows->changeMailingList().

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$name string No The updated workflow name.
$description string No The updated workflow description.

Example


workflows->delete()

Delete a workflow.

Successful deletion returns null (HTTP 204 No Content). If the workflow is currently sending or has queued contacts, the API returns HTTP 409. Retry with confirm_delete: true to delete the workflow, stop sending, and cancel queued contacts.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$confirm_delete boolean No Set to true after a confirmation-required 409 to confirm deleting a sending workflow or a workflow with queued contacts.

Example


workflows->changeMailingList()

Dry run or apply a workflow mailing list change.

If queued contacts would be removed, the API returns "status": "queuedContactsFound". Retry with queued_contact_policy: "discard" to apply the change.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$mailing_list_id string Yes The mailing list to use. Pass null to clear.
$dry_run boolean No If true, validate without modifying the workflow.
$queued_contact_policy string No fail (default) or discard.

Example


workflows->getNode()

Get detailed data for a single workflow node.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$node_id string Yes The ID of the workflow node.

Example


workflows->createNode()

Create a new default workflow node.

Use $insert_mode to choose placement:

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$insert_mode string Yes between, before, or after.
$node_type_name string Yes One of AudienceFilter, BranchNode, ExperimentBranchNode, TimerAction, SendEmailAction, VariantNode.
$from_node_id string Cond. Required for between and after. Not permitted for before.
$to_node_id string Cond. Required for between. For before, provide this or $before_node_id (not both). Not permitted for after.
$before_node_id string Cond. Deprecated. For before, provide this or $to_node_id (not both).

Example


workflows->updateNode()

Update workflow-node-owned fields for a single node.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$node_id string Yes The ID of the workflow node.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$payload array Yes Node-type-specific fields to update.

Example


workflows->deleteNode()

Delete a single workflow node.

If contacts are queued at the node, the API returns "status": "queuedContactsFound". Retry with queued_contact_policy: "discard" to delete.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$node_id string Yes The ID of the workflow node.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$dry_run boolean No If true, validate without modifying the workflow.
$queued_contact_policy string No fail (default) or discard.

Example


workflows->addBranch()

Add a branch and child node under an existing BranchNode or ExperimentBranchNode.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$node_id string Yes The ID of the branch or experiment node.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.

Example


workflows->rerouteNode()

Reroute a source node's outgoing connection to another valid target node. The source node must have exactly one outgoing connection. Branch and experiment branch nodes cannot be rerouted with this endpoint.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$node_id string Yes The ID of the source workflow node.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$new_target_node_id string Yes The node that should receive the connection.

Example


workflows->deleteNodeRecursive()

Delete a node and its downstream subtree.

API Reference

Parameters

Name Type Required Notes
$workflow_id string Yes The ID of the workflow.
$node_id string Yes The root node ID of the subtree to delete.
$expected_revision_id string|null Yes The latest workflow revision token. Pass null for older workflows.
$dry_run boolean No If true, validate without modifying the workflow.
$queued_contact_policy string No fail (default) or discard.

Example


eventPatterns->list()

List event patterns available to workflow event trigger nodes.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


eventPatterns->get()

Get an event pattern by ID.

API Reference

Parameters

Name Type Required Notes
$event_pattern_id string Yes The ID of the event pattern.

Example


eventPatterns->getByName()

Get an event pattern by event name. Event names are case-sensitive.

API Reference

Parameters

Name Type Required Notes
$event_name string Yes The exact event name.

Example


emailMessages->get()

Get an email message, including its compiled LMX content.

API Reference

Parameters

Name Type Required Notes
$email_message_id string Yes The ID of the email message.

Example


emailMessages->update()

Update an email message.

At least one field must be provided.

API Reference

Parameters

Name Type Required Notes
$email_message_id string Yes The ID of the email message.
$expected_revision_id string No Supply a value matching the current contentRevisionId to avoid 409 conflicts.
$subject string No The email subject line.
$preview_text string No The email preview text.
$from_name string No The sender name.
$from_email string No The sender email address (the name before the @; your sending domain will be automatically appended).
$reply_to_email string No The reply-to email address.
$cc_email string No CC email address. Requires the team to have CC/BCC enabled.
$bcc_email string No BCC email address. Requires the team to have CC/BCC enabled.
$language_code string No Language code for the email. Requires translation to be enabled for the team.
$email_format string No styled or plain.
$lmx string No The LMX content for the email message.
$contact_properties_fallbacks array No Contact property fallback values. Pass null as a value to remove an individual fallback entry.
$event_properties_fallbacks array No Event property fallback values. Pass null as a value to remove an individual fallback entry.
$data_variables_fallbacks array No Data variable fallback values. Pass null as a value to remove an individual fallback entry.

Example


emailMessages->preview()

Send a test preview of an email message to one or more addresses.

API Reference

Parameters

Name Type Required Notes
$email_message_id string Yes The ID of the email message.
$emails array Yes One or more addresses to send the preview to.
$contact_properties array No Contact property values to render. Accepted for campaign and workflow previews.
$event_properties array No Event property values to render. Accepted for workflow previews only.
$data_variables array No Transactional data variables to render. Accepted for transactional previews only.

Example


emailMessages->guardian()

Run Guardian content validation on an email message and return errors and warnings.

API Reference

Parameters

Name Type Required Notes
$email_message_id string Yes The ID of the email message.

Example


transactionalGroups->list()

List transactional groups.

API Reference

Parameters

Name Type Required Notes
$per_page integer No How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted.
$cursor string No A cursor, to return a specific page of results. Cursors can be found from the pagination.nextCursor value in each response.

Example


transactionalGroups->create()

Create a transactional group.

API Reference

Parameters

Name Type Required Notes
$name string Yes Cannot be the reserved name "Unsorted".
$description string No An optional description for the group.

Example


transactionalGroups->get()

Get a transactional group by ID.

API Reference

Parameters

Name Type Required Notes
$transactional_group_id string Yes The ID of the transactional group.

Example


transactionalGroups->update()

Update a transactional group's name or description.

At least one field alongside transactional_group_id must be provided.

API Reference

Parameters

Name Type Required Notes
$transactional_group_id string Yes The ID of the transactional group.
$name string No Cannot be the reserved name "Unsorted".
$description string No

Example


Testing


Contributing

Bug reports and pull requests are welcome. Please read our Contributing Guidelines.


All versions of loops with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package loops-so/loops contains the following files

Loading the files please wait ...