> ## Documentation Index
> Fetch the complete documentation index at: https://developers.redo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# customShippingMethodCode

> Get what is needed to write or edit a custom shipping method: the custom rate contract's TypeScript type definitions, starter code, and a sample input. Send `shippingMethodId` and `checkoutExperienceId` together to also get that method's current source. A shipping method that is not CUSTOM is null. An id from another account, or one that does not exist, is null.

**Required scopes:** [`checkout_read`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-checkout_read)

## Arguments

**checkoutExperienceId** `ID`

The checkout experience the custom method belongs to. Required with `shippingMethodId`.

**shippingMethodId** `ID`

A custom shipping method to read the current code of. Omit to get only the contract and starter code.

## Returns

**customShippingMethodCode** `[CustomShippingMethodCode](/docs/api-reference/v3/reference/checkout/custom-shipping-method-code)`

What is needed to write or edit a custom shipping method: the custom rate contract, starter code, and optionally one method's current source.

**fields**

**contractId** `String!` *required*

The custom rate contract every script is checked against.

**sampleInput** `String!` *required*

A representative `Input` value as JSON, showing the cart, destination, origin, and coverage data the script receives.

**shippingMethod** `[CustomShippingMethodSource](/docs/api-reference/v3/reference/checkout/custom-shipping-method-source)`

The requested method's current code. Null when no method was requested.

**fields**

**checkoutExperienceId** `ID!` *required*

The checkout experience the method belongs to.

**code** `String!` *required*

The method's current TypeScript source. Edit it and send it back as `code` to updateShippingMethod.

**name** `String!` *required*

Merchant-facing label of the method. Shoppers see the name the code returns instead.

**shippingMethodId** `ID!` *required*

The custom shipping method.

**starterCode** `String!` *required*

A minimal working script to start a new custom method from.

**typeDefinitions** `String!` *required*

TypeScript declarations of the contract: `Input`, `Output`, and the ambient `money` helper. Code that does not type-check against these is rejected on write.

## Example

```graphql theme={null}
query {
  customShippingMethodCode(checkoutExperienceId: "...", shippingMethodId: "...") {
    contractId
    sampleInput
    starterCode
    typeDefinitions
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.