# sp

Service Provider HTTP Operations

## Example

```ts
import * as SP from '@filoz/synapse-core/sp'
```

## Namespaces

| Namespace | Description |
| ------ | ------ |
| [addPieces](/reference/filoz/synapse-core/sp/namespaces/addpieces/toc/) | - |
| [addPiecesApiRequest](/reference/filoz/synapse-core/sp/namespaces/addpiecesapirequest/toc/) | - |
| [createDataSet](/reference/filoz/synapse-core/sp/namespaces/createdataset/toc/) | - |
| [createDataSetAndAddPieces](/reference/filoz/synapse-core/sp/namespaces/createdatasetandaddpieces/toc/) | - |
| [createDataSetAndAddPiecesApiRequest](/reference/filoz/synapse-core/sp/namespaces/createdatasetandaddpiecesapirequest/toc/) | - |
| [createDataSetApiRequest](/reference/filoz/synapse-core/sp/namespaces/createdatasetapirequest/toc/) | - |
| [createPieceBatcher](/reference/filoz/synapse-core/sp/namespaces/createpiecebatcher/toc/) | - |
| [deletePiece](/reference/filoz/synapse-core/sp/namespaces/deletepiece/toc/) | - |
| [deletePieces](/reference/filoz/synapse-core/sp/namespaces/deletepieces/toc/) | - |
| [findPiece](/reference/filoz/synapse-core/sp/namespaces/findpiece/toc/) | - |
| [getDataSet](/reference/filoz/synapse-core/sp/namespaces/getdataset/toc/) | - |
| [hasPiece](/reference/filoz/synapse-core/sp/namespaces/haspiece/toc/) | - |
| [isReachable](/reference/filoz/synapse-core/sp/namespaces/isreachable/toc/) | - |
| [ping](/reference/filoz/synapse-core/sp/namespaces/ping/toc/) | - |
| [prepareAddPieces](/reference/filoz/synapse-core/sp/namespaces/prepareaddpieces/toc/) | - |
| [prepareCreateDataSetAndAddPieces](/reference/filoz/synapse-core/sp/namespaces/preparecreatedatasetandaddpieces/toc/) | - |
| [pullPieces](/reference/filoz/synapse-core/sp/namespaces/pullpieces/toc/) | - |
| [pullPiecesApiRequest](/reference/filoz/synapse-core/sp/namespaces/pullpiecesapirequest/toc/) | - |
| [schedulePieceDeletion](/reference/filoz/synapse-core/sp/namespaces/schedulepiecedeletion/toc/) | - |
| [schedulePieceDeletions](/reference/filoz/synapse-core/sp/namespaces/schedulepiecedeletions/toc/) | - |
| [submitCommit](/reference/filoz/synapse-core/sp/namespaces/submitcommit/toc/) | - |
| [terminateService](/reference/filoz/synapse-core/sp/namespaces/terminateservice/toc/) | - |
| [terminateServiceApiRequest](/reference/filoz/synapse-core/sp/namespaces/terminateserviceapirequest/toc/) | - |
| [upload](/reference/filoz/synapse-core/sp/namespaces/upload/toc/) | - |
| [uploadPiece](/reference/filoz/synapse-core/sp/namespaces/uploadpiece/toc/) | - |
| [uploadPieces](/reference/filoz/synapse-core/sp/namespaces/uploadpieces/toc/) | - |
| [uploadPieceStreaming](/reference/filoz/synapse-core/sp/namespaces/uploadpiecestreaming/toc/) | - |
| [waitForAddPieces](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/toc/) | - |
| [waitForCreateDataSet](/reference/filoz/synapse-core/sp/namespaces/waitforcreatedataset/toc/) | - |
| [waitForCreateDataSetAddPieces](/reference/filoz/synapse-core/sp/namespaces/waitforcreatedatasetaddpieces/toc/) | - |
| [waitForDeletePieces](/reference/filoz/synapse-core/sp/namespaces/waitfordeletepieces/toc/) | - |
| [waitForFlushReceipt](/reference/filoz/synapse-core/sp/namespaces/waitforflushreceipt/toc/) | - |
| [waitForPullPieces](/reference/filoz/synapse-core/sp/namespaces/waitforpullpieces/toc/) | - |
| [waitForPullPiecesApiRequest](/reference/filoz/synapse-core/sp/namespaces/waitforpullpiecesapirequest/toc/) | - |
| [waitForSubmission](/reference/filoz/synapse-core/sp/namespaces/waitforsubmission/toc/) | - |
| [waitForTerminateService](/reference/filoz/synapse-core/sp/namespaces/waitforterminateservice/toc/) | - |

## Classes

| Class | Description |
| ------ | ------ |
| [AbortError](/reference/filoz/synapse-core/sp/classes/aborterror/) | - |
| [NetworkError](/reference/filoz/synapse-core/sp/classes/networkerror/) | - |
| [TimeoutError](/reference/filoz/synapse-core/sp/classes/timeouterror/) | - |

## Type Aliases

| Type Alias | Description |
| ------ | ------ |
| [AddPiecesCommit](/reference/filoz/synapse-core/sp/type-aliases/addpiecescommit/) | A signed add pieces commit from [prepareAddPieces](/reference/filoz/synapse-core/sp/functions/prepareaddpieces/), ready for [submitCommit](/reference/filoz/synapse-core/sp/functions/submitcommit/). |
| [BasePullPiecesOptions](/reference/filoz/synapse-core/sp/type-aliases/basepullpiecesoptions/) | Base options for pulling pieces. |
| [Commit](/reference/filoz/synapse-core/sp/type-aliases/commit/) | A signed commit, saved before sending so it can be resubmitted or recovered after a crash. |
| [CommitPiece](/reference/filoz/synapse-core/sp/type-aliases/commitpiece/) | One piece of a [Commit](/reference/filoz/synapse-core/sp/type-aliases/commit/), in JSON-safe form. |
| [CreateDataSetAndAddPiecesCommit](/reference/filoz/synapse-core/sp/type-aliases/createdatasetandaddpiecescommit/) | A signed create data set and add pieces commit from [prepareCreateDataSetAndAddPieces](/reference/filoz/synapse-core/sp/functions/preparecreatedatasetandaddpieces/), ready for [submitCommit](/reference/filoz/synapse-core/sp/functions/submitcommit/). |
| [CreateDataSetAndAddPiecesOptions](/reference/filoz/synapse-core/sp/type-aliases/createdatasetandaddpiecesoptions/) | - |
| [DataSet](/reference/filoz/synapse-core/sp/type-aliases/dataset/) | Data set from the PDP API. |
| [EnqueuePiece](/reference/filoz/synapse-core/sp/type-aliases/enqueuepiece/) | - |
| [FlushResult](/reference/filoz/synapse-core/sp/type-aliases/flushresult/) | - |
| [OnParked](/reference/filoz/synapse-core/sp/type-aliases/onparked/) | Called after the piece is on this SP, before it joins the addPieces window. The callback is awaited, so a thrown error keeps the piece out of the batch (retry with [PieceBatcher.enqueue](/reference/filoz/synapse-core/sp/type-aliases/piecebatcher/#enqueue)). [PieceBatcher.close](/reference/filoz/synapse-core/sp/type-aliases/piecebatcher/#close) waits for it the same way it waits for park/pull I/O. |
| [OnSubmitted](/reference/filoz/synapse-core/sp/type-aliases/onsubmitted/) | Called once per flushed window, after the provider accepts the addPieces (or createDataSetAndAddPieces) call and before any piece promise of that window settles. It is awaited, so it can persist the record first. |
| [PieceBatcher](/reference/filoz/synapse-core/sp/type-aliases/piecebatcher/) | - |
| [PieceBatcherWait](/reference/filoz/synapse-core/sp/type-aliases/piecebatcherwait/) | When to flush a tumbling addPieces window (limiter overflow, `flush()`, and `close()` always flush regardless). |
| [PieceResult](/reference/filoz/synapse-core/sp/type-aliases/pieceresult/) | - |
| [PullInput](/reference/filoz/synapse-core/sp/type-aliases/pullinput/) | - |
| [PullPieceInput](/reference/filoz/synapse-core/sp/type-aliases/pullpieceinput/) | Input piece for a pull request with typed PieceCID. |
| [PullPieceResult](/reference/filoz/synapse-core/sp/type-aliases/pullpieceresult/) | Status of one input piece, matched back to its position in the `pieces` input. |
| [PullToExistingDataSetOptions](/reference/filoz/synapse-core/sp/type-aliases/pulltoexistingdatasetoptions/) | Options for pulling pieces into an existing data set. |
| [PullToNewDataSetOptions](/reference/filoz/synapse-core/sp/type-aliases/pulltonewdatasetoptions/) | Options for creating a new data set and pulling pieces into it. |
| [PullWaitOptions](/reference/filoz/synapse-core/sp/type-aliases/pullwaitoptions/) | Options for waiting until a pull finishes, shared by [waitForPullPiecesApiRequest](/reference/filoz/synapse-core/sp/functions/waitforpullpiecesapirequest/) and [waitForPullPieces](/reference/filoz/synapse-core/sp/functions/waitforpullpieces/). |
| [SubmittedBatch](/reference/filoz/synapse-core/sp/type-aliases/submittedbatch/) | A flushed window that the provider accepted, before its transaction is confirmed. |
| [SubmittedPiece](/reference/filoz/synapse-core/sp/type-aliases/submittedpiece/) | One piece of a [SubmittedBatch](/reference/filoz/synapse-core/sp/type-aliases/submittedbatch/), in JSON-safe form. |
| [TerminateServiceStatusPending](/reference/filoz/synapse-core/sp/type-aliases/terminateservicestatuspending/) | - |
| [TerminateServiceStatusResponse](/reference/filoz/synapse-core/sp/type-aliases/terminateservicestatusresponse/) | - |
| [TerminateServiceStatusSuccess](/reference/filoz/synapse-core/sp/type-aliases/terminateservicestatussuccess/) | - |
| [UploadInput](/reference/filoz/synapse-core/sp/type-aliases/uploadinput/) | - |
| [UploadPieceStreamingData](/reference/filoz/synapse-core/sp/type-aliases/uploadpiecestreamingdata/) | Data accepted by [uploadPieceStreaming](/reference/filoz/synapse-core/sp/functions/uploadpiecestreaming/). |
| [UploadResult](/reference/filoz/synapse-core/sp/type-aliases/uploadresult/) | - |

## Variables

| Variable | Description |
| ------ | ------ |
| [DataSetSchema](/reference/filoz/synapse-core/sp/variables/datasetschema/) | - |
| [TerminateServiceStatusPendingSchema](/reference/filoz/synapse-core/sp/variables/terminateservicestatuspendingschema/) | Schema for the termination status while the provider's transaction is pending. The hash is empty until the provider's relay task sends the transaction. |
| [TerminateServiceStatusSuccessSchema](/reference/filoz/synapse-core/sp/variables/terminateservicestatussuccessschema/) | Schema for the confirmed termination status. The hash may be empty when the service was already terminated on chain without a provider transaction. |

## Functions

| Function | Description |
| ------ | ------ |
| [addPieces](/reference/filoz/synapse-core/sp/functions/addpieces/) | Add pieces to a data set |
| [addPiecesApiRequest](/reference/filoz/synapse-core/sp/functions/addpiecesapirequest/) | Add pieces to a data set on the PDP API. |
| [createDataSet](/reference/filoz/synapse-core/sp/functions/createdataset/) | Create a data set |
| [createDataSetAndAddPieces](/reference/filoz/synapse-core/sp/functions/createdatasetandaddpieces/) | Create a data set and add pieces to it |
| [createDataSetAndAddPiecesApiRequest](/reference/filoz/synapse-core/sp/functions/createdatasetandaddpiecesapirequest/) | Create a data set and add pieces to it on PDP API |
| [createDataSetApiRequest](/reference/filoz/synapse-core/sp/functions/createdatasetapirequest/) | Create a data set on PDP API |
| [createPieceBatcher](/reference/filoz/synapse-core/sp/functions/createpiecebatcher/) | Create a stateful piece batcher that parks/pulls immediately and coalesces addPieces. |
| [~~deletePiece~~](/reference/filoz/synapse-core/sp/functions/deletepiece/) | Delete one piece from a data set on the PDP API. |
| [deletePieces](/reference/filoz/synapse-core/sp/functions/deletepieces/) | Delete pieces from a data set on the PDP API in one transaction. |
| [findPiece](/reference/filoz/synapse-core/sp/functions/findpiece/) | Find a piece on the PDP API. |
| [~~getDataSet~~](/reference/filoz/synapse-core/sp/functions/getdataset/) | Get a data set from the PDP API. |
| [hasPiece](/reference/filoz/synapse-core/sp/functions/haspiece/) | Check whether a provider has a piece. |
| [isReachable](/reference/filoz/synapse-core/sp/functions/isreachable/) | Check whether a provider's PDP API answers a ping. |
| [ping](/reference/filoz/synapse-core/sp/functions/ping/) | Ping the PDP API. Resolves when the provider answers with a 2xx status. |
| [prepareAddPieces](/reference/filoz/synapse-core/sp/functions/prepareaddpieces/) | Sign an add pieces commit and return it as JSON-safe data, without sending it. |
| [prepareCreateDataSetAndAddPieces](/reference/filoz/synapse-core/sp/functions/preparecreatedatasetandaddpieces/) | Sign a create data set and add pieces commit and return it as JSON-safe data, without sending it. |
| [pullPieces](/reference/filoz/synapse-core/sp/functions/pullpieces/) | Pull pieces from external storage providers into a data set. |
| [pullPiecesApiRequest](/reference/filoz/synapse-core/sp/functions/pullpiecesapirequest/) | Initiate a piece pull request or get status of an existing one. |
| [~~schedulePieceDeletion~~](/reference/filoz/synapse-core/sp/functions/schedulepiecedeletion/) | Schedule one piece deletion. |
| [schedulePieceDeletions](/reference/filoz/synapse-core/sp/functions/schedulepiecedeletions/) | Schedule piece deletions in one transaction. |
| [submitCommit](/reference/filoz/synapse-core/sp/functions/submitcommit/) | Send a commit from [prepareAddPieces](/reference/filoz/synapse-core/sp/functions/prepareaddpieces/) or [prepareCreateDataSetAndAddPieces](/reference/filoz/synapse-core/sp/functions/preparecreatedatasetandaddpieces/) to the PDP API. |
| [terminateService](/reference/filoz/synapse-core/sp/functions/terminateservice/) | Terminate a data set service via the service provider |
| [terminateServiceApiRequest](/reference/filoz/synapse-core/sp/functions/terminateserviceapirequest/) | Request data set termination on the PDP API. |
| [terminateServiceStatusUrl](/reference/filoz/synapse-core/sp/functions/terminateservicestatusurl/) | Build the termination status URL for a data set, pollable with [waitForTerminateService](/reference/filoz/synapse-core/sp/functions/waitforterminateservice/). Useful for resuming tracking of a previously requested termination. |
| [upload](/reference/filoz/synapse-core/sp/functions/upload/) | Upload multiple pieces to a data set on the PDP API. |
| [uploadPiece](/reference/filoz/synapse-core/sp/functions/uploadpiece/) | Upload a piece to the PDP API. |
| [uploadPieces](/reference/filoz/synapse-core/sp/functions/uploadpieces/) | Upload pieces to an existing data set and add them in one signed request. |
| [uploadPieceStreaming](/reference/filoz/synapse-core/sp/functions/uploadpiecestreaming/) | Upload piece data using the 3-step CommP-last streaming protocol. |
| [validateDeletePiecesBatch](/reference/filoz/synapse-core/sp/functions/validatedeletepiecesbatch/) | Validate a delete-pieces batch before signing or sending it. |
| [waitForAddPieces](/reference/filoz/synapse-core/sp/functions/waitforaddpieces/) | Wait for an add pieces transaction on chain, following replace-by-fee replacements. |
| [waitForCreateDataSet](/reference/filoz/synapse-core/sp/functions/waitforcreatedataset/) | Wait for a create data set transaction on chain, following replace-by-fee replacements. |
| [waitForCreateDataSetAddPieces](/reference/filoz/synapse-core/sp/functions/waitforcreatedatasetaddpieces/) | Wait for a create data set and add pieces transaction on chain, following replace-by-fee replacements. |
| [waitForDeletePieces](/reference/filoz/synapse-core/sp/functions/waitfordeletepieces/) | Wait for a schedule piece deletions transaction on chain, following replace-by-fee replacements. |
| [waitForFlushReceipt](/reference/filoz/synapse-core/sp/functions/waitforflushreceipt/) | Wait for a flushed batch to land on chain and get its piece IDs. |
| [waitForPullPieces](/reference/filoz/synapse-core/sp/functions/waitforpullpieces/) | Wait for pull pieces completion. |
| [waitForPullPiecesApiRequest](/reference/filoz/synapse-core/sp/functions/waitforpullpiecesapirequest/) | Wait for pull pieces completion API request. |
| [waitForTerminateService](/reference/filoz/synapse-core/sp/functions/waitforterminateservice/) | Wait for the data set termination status. |