@zavudev/sdk 0.59.0 and later calls API v2 as client.v2,
on the same client, API key, retries and pagination as v1. v1 stays where it
was: client.messages is v1, client.v2.messages is v2, and the two can be
mixed in one codebase.
Ids are positional
Every id in a v2 path is an argument, in the order the path has it. Body and query fields go in the object after them.GET /v2/channels. The SDK puts it in the
path for you; you do not encode the + yourself.
Types
v2’sMessage, Contact and Template are not v1’s, so v2’s types have their
own entry point:
@zavudev/sdk keeps exporting v1’s types, as before.
Lists
A list call pages for you. Iterate it to follownextCursor to the end, or
read one page:
Errors
A failed call throws the same classes as v1, from the root of the package. A v2 error body is{code, message, details} at the root, and the SDK keeps it on
error.error:
409 is a ConflictError and is not retried: v2 answers it with
x-should-retry: false, and the SDK reads that header. See
Errors.
Methods
What v2 does not cover (voice calls, 10DLC, memory, sub-accounts and the rest
listed in Migrate from v1) stays on the v1 methods of
the same client.
