# Validate An Address — Shipengine

> Address validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. See the docs.

- Key: `shipengine-validate-address`
- Type: Action (Read-only)
- Version: 0.0.3
- App: Shipengine (`shipengine`) — https://pipedream.com/apps/shipengine.md
- This page (HTML): https://pipedream.com/apps/shipengine/actions/validate-address
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/shipengine/actions/validate-address/validate-address.mjs

## Description

Address validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. [See the docs](https://shipengine.github.io/shipengine-openapi/#operation/validate_address).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | No | The name of a contact person at this address. |
| `phone` | `string` | No | The phone number of a contact person at this address. The format of this phone number varies depending on the country. |
| `cityLocality` | `string` | Yes | The name of the city or locality. |
| `stateProvince` | `string` | Yes | The state or province. For some countries (including the U.S.) only abbreviations are allowed. Other countries allow the full name or abbreviation. |
| `countryCode` | `string` | Yes | The two-letter ISO 3166-1 country code. |
| `addressLine1` | `string` | Yes | The first line of the street address. For some addresses, this may be the only line. Other addresses may have two or three lines. |
| `addressLine2` | `string` | No | The second line of the street address. |
| `addressLine3` | `string` | No | The third line of the street address. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "shipengine",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "shipengine-validate-address",
  arguments: {
    name: "Name",
    phone: "Phone",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "shipengine-validate-address",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    shipengine: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    phone: "Phone",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "shipengine-validate-address",
    "configured_props": {
      "shipengine": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "phone": "Phone"
    }
  }'
```

---

- App: https://pipedream.com/apps/shipengine.md · All apps: https://pipedream.com/apps
