SazitoSazito SDKv1.2.5
API Reference

Shipping

Shipping address and method APIs used during checkout address selection and delivery assignment.

Module role in sales flow

shipping manages buyer destination data and available delivery channels.

  • Use createAddress for checkout. Each submitted address must be a new, immutable order snapshot.
  • Use listAddresses to prefill the latest address for an authenticated user.
  • Use getAddress to prefill a guest address from locally stored credentials.
  • Use getMethods for a global shipping-method list.
  • For checkout-ready, invoice-specific rates, use invoices.getApplicableShippingMethods().

V2 contract notes

  • address.mobilePhone is required for create/update flows.
  • regionId and cityId are optional in request contract.
  • getAddress() uses stored identifier query behind the scenes.
  • Do not use updateAddress() in checkout: the backend mutates the referenced row, which can change the address shown on previous orders.

Methods

Create Address

Use: shipping.createAddress(address, options?).

FieldTypeRequiredDescription
address.firstNamestringRequiredRecipient first name.
address.lastNamestringRequiredRecipient last name.
address.mobilePhonestringRequiredRecipient mobile phone.
address.regionIdnumberOptionalRegion ID.
address.cityIdnumberOptionalCity ID.
address.addressstringRequiredStreet address.
address.phoneNumberstringOptionalSecondary phone number.
address.emailstringOptionalContact email.
address.postalCodestringOptionalPostal code.
address.latitudenumberOptionalGeo latitude.
address.longitudenumberOptionalGeo longitude.
address.showMapbooleanOptionalStorefront map-visibility flag.
address.userSetCoordinatesBeforebooleanOptionalManual coordinate flag.
const addressRes = await client.shipping.createAddress({
  firstName: 'John',
  lastName: 'Doe',
  mobilePhone: '09123456789',
  regionId: 1,
  cityId: 10,
  address: 'No. 10, Example St',
  postalCode: '1234567890',
});

Update Address

Use: shipping.updateAddress(address, options?).

Deprecated for checkout. This mutates the existing address row. Use createAddress() to preserve historical order snapshots.

Same input schema as createAddress.

await client.shipping.updateAddress({
  firstName: 'John',
  lastName: 'Doe',
  mobilePhone: '09121234567',
  regionId: 1,
  cityId: 10,
  address: 'Unit 8, Updated Address',
  postalCode: '1234567890',
});

List Authenticated User Addresses

Use: shipping.listAddresses(options?).

Returns the authenticated user's normalized addresses newest first. This request is not cached, so the first item is safe to use as checkout prefill.

const addressesRes = await client.shipping.listAddresses();
const latestAddress = addressesRes.data?.[0];

Get Guest Address

Use: shipping.getAddress(options?).

Returns: SazitoResponse<ShippingAddress>.

const addressRes = await client.shipping.getAddress();

Get Methods

Use: shipping.getMethods(options?).

Returns: SazitoResponse<ShippingMethod[]>.

const shippingMethodsRes = await client.shipping.getMethods();

Clear Address

Use: shipping.clearAddress().

Clears persisted shipping credentials.

client.shipping.clearAddress();

ShippingMethod fields

FieldTypeRequiredDescription
idnumberRequiredMethod ID.
namestringRequiredMethod name.
typestringRequiredShipping method type code.

Known errors

TypeWhen it happens
validationMissing shipping credentials for getAddress.

Examples

// app/lib/sazito-client.ts
import { createSazitoClient } from '@sazito/client-sdk';

export const sazito = createSazitoClient({
  domain: process.env.NEXT_PUBLIC_SAZITO_DOMAIN!,
});
// app/[lang]/(home)/page.tsx
'use client';
import { useEffect, useState } from 'react';
import { sazito } from '@/app/lib/sazito-client';

export default function Example() {
  const [data, setData] = useState<any>(null);

  useEffect(() => {
    sazito.shipping.createAddress({
      firstName: 'John',
      lastName: 'Doe',
      mobilePhone: '09123456789',
      regionId: 1,
      cityId: 10,
      address: 'No. 10, Example St',
      postalCode: '1234567890',
    }).then((res) => setData(res.data ?? null));
  }, []);

  return <pre>{JSON.stringify(data, null, 2)}</pre>;
}

Type Details

The following tables are generated from SDK TypeScript types and include nested object fields.

ShippingAddressInput

Source: src/types/shipping.ts

FieldTypeRequired
firstNamestringRequired
lastNamestringRequired
mobilePhonestringOptional
phoneNumberstringOptional
emailstringOptional
regionIdnumberRequired
cityIdnumberRequired
addressstringRequired
postalCodestringOptional
latitudenumberOptional
longitudenumberOptional
userSetCoordinatesBeforebooleanOptional

ShippingAddress

Source: src/types/invoice.ts

FieldTypeRequired
idnumberRequired
identifierstringRequired
firstNamestringRequired
lastNamestringRequired
mobilePhonestringOptional
phoneNumberstringOptional
emailstringOptional
regionRegionOptional
cityCityRequired
addressstringRequired
postalCodestringOptional
latitudenumberOptional
longitudenumberOptional
userSetCoordinatesBeforebooleanOptional
createdAtstringOptional
updatedAtstringOptional

ShippingMethod

Source: src/types/shipping.ts

FieldTypeRequired
idnumberRequired
namestringRequired
typestringRequired

ShippingRate

Source: src/types/shipping.ts

FieldTypeRequired
idnumberRequired
namestringRequired
pricenumberRequired
descriptionstringOptional
iconstringOptional
colorstringOptional
typestringOptional

On this page