# terminateService

> **terminateService**(`client`, `options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/sp/namespaces/terminateserviceapirequest/type-aliases/outputtype/)\>

Defined in: [packages/synapse-core/src/sp/terminate-service.ts:231](https://github.com/FilOzone/synapse-sdk/blob/ac439ced73387be0f1e7ed7e635dce4bdba76399/packages/synapse-core/src/sp/terminate-service.ts#L231)

Terminate a data set service via the service provider

Signs a termination authorization and sends it to the provider, which relays
it on chain. Provider-relayed termination takes effect immediately when the
transaction lands (no lockup wind-down); it fails instead if the payer's
account cannot settle in full. The direct on-chain alternative
(`warm-storage/terminate-service`) needs no provider cooperation but the
service runs to the end of the lockup period.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `client` | `Client`\<`Transport`, `Chain`, `Account`\> | The client to use to sign the termination authorization. |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/terminateservice/type-aliases/optionstype/) | [terminateService.OptionsType](/reference/filoz/synapse-core/sp/namespaces/terminateservice/type-aliases/optionstype/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/sp/namespaces/terminateserviceapirequest/type-aliases/outputtype/)\>

Status URL to poll with [waitForTerminateService](/reference/filoz/synapse-core/sp/functions/waitforterminateservice/). [terminateService.OutputType](/reference/filoz/synapse-core/sp/namespaces/terminateservice/type-aliases/outputtype/)

## Throws

Errors [terminateService.ErrorType](/reference/filoz/synapse-core/sp/namespaces/terminateservice/type-aliases/errortype/)

## Example

```ts
import { terminateService, waitForTerminateService } from '@filoz/synapse-core/sp'
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { calibration } from '@filoz/synapse-core/chains'

const account = privateKeyToAccount('0x...')
const client = createWalletClient({
  account,
  chain: calibration,
  transport: http(),
})

const { statusUrl } = await terminateService(client, {
  dataSetId: 1n,
  serviceURL: 'https://pdp.example.com',
})
const status = await waitForTerminateService({ statusUrl })
console.log(status.serviceTerminationEpoch)
```