# Get Insurance Rate — Deftship

> Checks pricing for Insurance based on the supplied information. Also automatically creates an insurance and returns the pricing. See the documentation

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

## Description

Checks pricing for Insurance based on the supplied information. Also automatically creates an insurance and returns the pricing. [See the documentation](https://developer.deftship.com/insurance/get-rates)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `carrier` | `string` | Yes | Carrier of the order going to be insured Options are loaded from the connected account. |
| `serviceCode` | `string` | Yes | Service code of this order Options are loaded from the connected account. |
| `shipmentDate` | `string` | Yes | Shipment date, in Y-m-d |
| `fromName` | `string` | Yes | The name in the sender address |
| `fromAttention` | `string` | Yes | Attention of the sender |
| `fromStreet` | `string` | Yes | The street address of the sender |
| `fromCity` | `string` | Yes | The city address of the sender |
| `fromState` | `string` | Yes | The state code of the sender |
| `fromZip` | `string` | Yes | The zip code of the sender |
| `fromCountry` | `string` | Yes | The country code of the sender |
| `fromTelephone` | `string` | Yes | The telephone number of the sender |
| `toName` | `string` | Yes | The name in the receiver address |
| `toAttention` | `string` | Yes | Attention of the receiver |
| `toStreet` | `string` | Yes | The street address of the receiver |
| `toCity` | `string` | Yes | The city address of the receiver |
| `toState` | `string` | Yes | The state code of the receiver |
| `toZip` | `string` | Yes | The zip code of the receiver |
| `toCountry` | `string` | Yes | The country code of the receiver |
| `toTelephone` | `string` | Yes | The telephone number of the receiver |
| `trackingNumber` | `string` | Yes | Tracking number of the package going to be insured |
| `itemDescription` | `string` | Yes | Description of the item being shipped |
| `itemQuantity` | `integer` | Yes | Item piece count |
| `itemPrice` | `string` | Yes | Item piece price |
| `isInternational` | `boolean` | No | Set to true if the shipment is international |
| `isFreight` | `boolean` | No | Set to true if the shipment is freight |

## 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": "deftship",
      },
    },
  },
)

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: "deftship-get-insurance-rate",
  arguments: {
    carrier: "Insurance Carrier",
    serviceCode: "Service Code",
  },
})
```

**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: "deftship-get-insurance-rate",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    deftship: { authProvisionId: "apn_xxxxxxx" },
    carrier: "Insurance Carrier",
    serviceCode: "Service Code",
  },
})

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": "deftship-get-insurance-rate",
    "configured_props": {
      "deftship": { "authProvisionId": "apn_xxxxxxx" },
      "carrier": "Insurance Carrier",
      "serviceCode": "Service Code"
    }
  }'
```

---

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