laylo/laylo
Skills for building with the Laylo API: set up and verify credentials, then answer questions about an account's drops, fans, and conversions with the Node SDK or plain HTTP.
@laylo.com/node
0.11.0
Minor Changes
-
d9b0fc9:
fans.isSubscribedandfans.isUnsubscribedcan check up to 500 contacts in one request. Pass{ email: [...] }or{ phone: [...] }and the call resolves to aboolean[]with one answer per contact, in request order; a single contact still resolves to aboolean, and a value typed as either form resolves toboolean | boolean[]. Read-only arrays andas consttuples are accepted. An empty array or more than 500 contacts throwsLayloConfigurationErrorbefore anything is sent, and an invalid entry fails the whole call withBadRequestErrornaming its index. The newContactBatchtype describes the array form, and the newSubscriptionBatchCheckResponseandUnsubscriptionBatchCheckResponsetypes describe the batch responses.SubscriptionCheckResponseandUnsubscriptionCheckResponseare unchanged.Type-level change for anyone using the raw query types:
ListConversionsParams['action']narrows fromstring[]to the documented conversion actions, andListConversionCountsParams['action']no longer includesRSVP. Code that builds these types withRSVPor an arbitrary string will stop compiling.conversions.listandconversions.counts.listare not affected: their inputs still acceptRSVP, and so does the API.
0.10.0
Minor Changes
- ea321a7:
fans.subscribe(fan)no longer needs consent fields. Pass anemail, aphone, or both, and optionally adropId; the fan's sign-up time is the time of the call.consentGrantedAt,emailMarketingConsent, andsmsMarketingConsentare still accepted so existing code compiles, but they're deprecated and the SDK no longer sends them, since the API stopped reading them. A consent flag next to its contact is typed astrueonly, and passingfalsethere throws aLayloConfigurationErrorrather than subscribing a fan who declined. The response now typesrejected, which lists a contact that couldn't be subscribed when the other one in the same call was, andemailFanIdandphoneFanIdare present only for a contact that subscribed.
0.9.0
Minor Changes
-
b158591:
conversions.events.track(event)follows the API's current request shape.metadatanow types the fields Laylo recognizes, includingcity,state, andcountry: sendcityandcountrytogether and Laylo attaches that location to the fan if they don't already have one.useraccepts extra fields, which are stored but not echoed back, and needs anemailorphone. When an event has nosource, the API fills it from theX-Laylo-Sourceheader and then from the API key's label.Breaking:
user.fingerprintId,user.isAnonymous, andcreateNeoRecordare gone from the request types, andactionno longer includes"RSVP". The API ignores the first two, rejectscreateNeoRecordwith a 400, and rejectsuser.phoneNumbertoo, so identify the fan withemailorphoneand drop the rest. To RSVP a fan to a drop, usefans.subscribewith adropId.TrackedConversionno longer hascreateNeoRecord,user.fingerprintId, oruser.isAnonymous.
0.8.0
Minor Changes
- 055502f: New
laylo.billing.creditUsageresource for the public API's credit usage endpoints.get(params?)returns the message credits a customer used over a window of UTC days, per channel, with a series bucketed by day, week, or month.getForProducts({ productIds, ...params })returns the same report summed across specific drops and segment messages.startDateandendDateare UTC days asYYYY-MM-DDstrings. New types:CreditUsageReport,CreditUsageByProductReport,CreditUsage,CreditUsageBucket,ChannelCreditUsage,CreditChannel,CreditRates,CreditUsageInterval,GetCreditUsageParams,GetProductCreditUsageParams, andGetProductCreditUsageInput.
Patch Changes
- 4eb705c: Docs: an API-key-only client is limited to 20 requests a minute per account by default, and Laylo can raise the limit on a specific key, which then gets its own budget.
0.7.0
Minor Changes
- b47bc0c:
messages.segments.send(input)andmessages.segments.schedule(input)can now email a segment as well as text one. Passsegment.signUpType: "email"withemail: { subject, ctaUrl?, ctaText? }; Laylo lays the email out frommessage, turns its links into buttons, and addsctaUrlwithctaTextas the main button. An email segment withoutemail, oremailon an SMS segment, throwsLayloConfigurationErrorbefore any request. New type:SegmentMessageEmail.
0.6.0
Minor Changes
- 4d06b16: Add
messages.segments.send(input)andmessages.segments.schedule(input), which text every SMS fan in a segment, either within the next few minutes or at a local date and time in a given time zone. The segment takes the same filters asfans.segments.count, withsignUpType: "sms", and its sign-up bounds accept aDateas well as an ISO 8601 string. Both resolve to{ id, note, sendAt, dryRun, estimate }, whereestimategives the expected recipients, credits, and cost in US dollars. PassdryRun: trueto get the estimate without sending anything;idis then null. They're writes, so a server error isn't retried unless the call passes anidempotencyKeyin its options. The key is sent as theIdempotency-Keyheader and makes a repeat within 24 hours return the first response instead of sending again, so the SDK then retries server errors, dropped connections, and a409from an earlier attempt that hasn't finished. A segment with bothsignedUpAfterandsignedUpBefore, or a malformed key, throwsLayloConfigurationErrorbefore any request. New types:SendSegmentMessageInput,ScheduleSegmentMessageInput,MessageSegmentInput,SegmentMessageOptions,SendSegmentMessageRequest,ScheduleSegmentMessageRequest,MessageSegment,SegmentMessageTimezone,SegmentMessage, andSegmentMessageEstimate.
0.5.0
Minor Changes
-
cea3bf0: A Laylo account calling its own data can now authenticate with just its API key.
new Laylo({ apiKey }), ornew Laylo()with onlyLAYLO_API_KEYset, sends the key asX-Api-Keywith no access token, so integrator credentials aren't needed. The client works this way whenever none ofuserId,accessKey, andsecretKeyis set; setting some but not all of them still throws. Naming any of the three in code, even as"", now turns their environment variables off for all three, matching howapiKeyandcreatorIdalready work, so a strayLAYLO_USER_IDcan be ignored withuserId: "". This changes one existing setup: passing some integrator credentials in code and leaving the rest to their environment variables, such as{ userId }withLAYLO_ACCESS_KEYandLAYLO_SECRET_KEYset, now throws. Pass all three in code, or none. Passing them asundefined(for example straight fromprocess.env) with none set in the environment either throws instead of quietly falling back to the API key. These clients are limited to 20 requests a minute per account and can only act on the key's own account: acreatorId(in the constructor,LAYLO_CREATOR_ID,forCustomer, or a call's options) throwsLayloConfigurationError, andcustomers.list()andauth.createToken()reject withLayloConfigurationErrorwithout sending a request. Constructing a client with no credentials at all now throws an error that describes both ways to authenticate. On such a client,toJSON()reportsuserId,accessKey, andsecretKeyasundefined, so their types now includeundefined.A key used on its own is also bound by its permissions in Laylo: writes (
fans.subscribe,conversions.events.track,messages.sms.send) need the key's "write" permission and every other call exceptkeys.verify()needs "read". A key without the permission a call needs gets aPermissionError; a key with no permissions stored can only read, and one whose permissions are an empty list can only verify itself. Keys can't be granted "write" yet, so for now key-only clients are read-only.toJSON()(and soutil.inspect) now includes amodeof"integrator"or"apiKey", so a deploy check can assert which way the client authenticates. -
47af2b7:
fans.subscribenow accepts anemailand aphonetogether, each with its consent flag set totrue. Both channels are subscribed and the two records are linked as the same person. It previously threw aLayloConfigurationErrorfor a fan with both; a fan with neither still throws, and so now does a blank (empty or whitespace-only)emailorphone, which used to reach the API and fail there.SubscribeFanInputandSubscribeFanRequestgain the both-channels variant.Breaking: the response no longer has
fan. It carriesemailFanIdandphoneFanIdinstead, each present only when that contact was given. Replacefan.idwithemailFanIdfor an email subscribe orphoneFanIdfor a phone subscribe; a call with both returns both ids, one for each record.
0.4.0
Minor Changes
- c70e2f6: Add
messages.sms.send(sms), which texts a message from the customer's Laylo number to one E.164 phone number or up to 200 at once. Only numbers that currently subscribe to the customer are texted. It resolves to{ queued, skipped }, whereskippedreports each recipient that wasn't texted by its index into, with a reason of"not_subscribed","duplicate", or"queue_failed". As a write, it is not retried on a server error. New types:SendSmsRequest,SendSmsResponse, andSkippedRecipient.
0.3.0
Minor Changes
- b8b17a5: Wrap the four public endpoints the SDK was missing.
customers.list()returns the accounts under your integration's own Laylo account, whose ids are whatforCustomer({ creatorId })accepts.conversions.counts.list(params?)reports conversion event counts per action over a window, with a daily series for each.fans.segments.count(filters)resolves to the number of fans matching a segment.fans.subscribe(fan)subscribes a fan with an explicit marketing-consent record and can RSVP them to a drop in the same call; as a write it is not retried on a server error. Date-valued inputs (consentGrantedAt,startDate,endDate,signedUpAfter,signedUpBefore) accept aDateas well as an ISO 8601 string. New types:CustomerAccount,ConversionCountsReport,ConversionCount,ConversionCountBucket,ListConversionCountsParams,ListConversionCountsInput,SegmentFilters,SegmentLocation,SegmentCountResponse,CountFansInput,SubscribeFanRequest,SubscribeFanInput, andSubscribeFanResponse. - b8b17a5: Integrator credentials are now passed as three options instead of a joined client id.
new Laylo({ userId, accessKey, secretKey })replacesclientIdandclientSecret, and the environment fallbacks areLAYLO_USER_ID,LAYLO_ACCESS_KEY, andLAYLO_SECRET_KEYin place ofLAYLO_CLIENT_IDandLAYLO_CLIENT_SECRET. The SDK joins the user id and access key into theclient_idthe token endpoint expects, so you no longer build<userId>.<accessKey>yourself.
Patch Changes
- b8b17a5:
LayloAPIError.requestIdis now set on errors from the production API, which sends the request id in theapigw-requestidheader.
0.2.0
Minor Changes
- 13f70bd: Name a customer by
creatorIdinstead of an API key. Enterprise integrations can act on any account under their own Laylo account by passing its user id to the constructor (orLAYLO_CREATOR_ID), toforCustomer({ creatorId }), or in a call'sRequestOptions. The SDK sends it asX-Creator-Id, andkeys.verify()resolves withapiKeyStatus: "not_provided"for such a customer. - 4a39744: Trim the SDK to the endpoints the public API has launched.
conversions.definitions.create,conversions.definitions.retrieve,conversions.events.list,fans.segments.count, andmessages.scheduled.listare removed, along with thePagepagination helpers and the types that only those methods used. The remaining methods arekeys.verify,drops.list,conversions.list,conversions.events.track,fans.isSubscribed,fans.isUnsubscribed, andauth.createToken.
0.1.0
Minor Changes
- d5567ba: First release of the SDK: a client with keys, drops, conversions, fans, and messages resources, cursor-based pagination, typed errors, automatic retries, and dual ESM/CJS builds.