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

# Go SDK

> Install the Go client, authenticate, and call the API.

The Go client is
`github.com/parable-platform/platform-schemas/sdk/go/web-api`. It covers
every operation in the [API reference](https://developers.askparable.com/api-reference/overview.md).

## Install

The module is in a private Go module proxy. Ask your Parable representative
for access. Then add the client and its types:

```bash theme={null}
go get github.com/parable-platform/platform-schemas/sdk/go/web-api
go get github.com/parable-platform/platform-schemas/types/go/web-api
```

## Import and authenticate

Create a client with the base URL, your token, and your Workspace. See
[Authentication](https://developers.askparable.com/getting-started/authentication.md) to get a token.

```go theme={null}
package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"os"

	webapisdk "github.com/parable-platform/platform-schemas/sdk/go/web-api"
	webapitypes "github.com/parable-platform/platform-schemas/types/go/web-api"
)

func main() {
	baseURL := os.Getenv("PARABLE_API_URL")
	token := os.Getenv("PARABLE_API_TOKEN")
	workspace := os.Getenv("PARABLE_WORKSPACE") // for example "acme-corp"
	if baseURL == "" || token == "" || workspace == "" {
		log.Fatal("Set PARABLE_API_URL, PARABLE_API_TOKEN, and PARABLE_WORKSPACE")
	}

	sdk, err := webapisdk.New(webapisdk.SDKConfig{
		BaseURL: baseURL,
		Auth:    &webapisdk.AuthConfig{Token: token},
		RequestInterceptor: func(ctx context.Context, req *http.Request) error {
			req.Header.Set("X-Tenant", workspace)
			return nil
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()

	// The Read and Update steps below continue here.
}
```

The client sends `Authorization: Bearer ...` on every call. The
`RequestInterceptor` adds the `X-Tenant` header.

## Read

Read your membership, then the Provider connections in your Workspace:

```go theme={null}
me, err := sdk.UsersNamespace.Me(ctx)
if err != nil {
	log.Fatal(err)
}
fmt.Println(me.Name, me.Email)

connections, err := sdk.VendorsNamespace.TenantConnectorInstances(ctx, nil)
if err != nil {
	log.Fatal(err)
}
for _, connection := range connections {
	fmt.Println(connection.Id, connection.ConnectionStatus)
}
```

## Update

Stop a Tap. This call needs a Parable token, because an MCP token only
reads. Replace the ID with one from your Workspace. List Taps with
`sdk.TenantConnectorTapsNamespace.TenantConnectorTaps(ctx, nil)`.

```go theme={null}
tap, err := sdk.TenantConnectorTapsNamespace.UpdateTenantConnectorTap(
	ctx,
	"018f2a3b-9c4d-7e5f-8a6b-1c2d3e4f5a6b",
	webapitypes.UpdateTenantConnectorTapInput{
		Enabled: webapitypes.InputField[bool]{Set: true, Value: false},
	},
)
if err != nil {
	log.Fatal(err)
}
fmt.Println(tap.Id, tap.Enabled)
```

The update leaves omitted fields unchanged. `enabled: false` stops the Tap.
`enabled: true` does not add a Tap that the connection's `enabledTaps`
leaves out. To turn on an opt-in Tap, see
[Turn Taps on and off](https://developers.askparable.com/connectors/taps.md#turn-taps-on-and-off).

## Encrypt credentials

Two operations take an encrypted body, such as
`sdk.ConnectorsNamespace.AddConnectorToTenant`. Get your Workspace's public
key and give it to the client once. The client then encrypts the body of
each of these operations:

```go theme={null}
key, err := sdk.SecurityNamespace.EncryptionKey(ctx)
if err != nil {
	log.Fatal(err)
}
sdk.SetPublicEncryptionKey(&webapisdk.PublicEncryptionKey{
	PublicKey: string(key.PublicKey),
	Algorithm: string(key.Algorithm),
	KeyID:     key.KeyId,
})
```

You can also set `Encryption: &webapisdk.EncryptionConfig{PublicEncryptionKey: ...}`
in `SDKConfig`, or pass `&webapisdk.EncryptedRequestOptions{PublicEncryptionKey: ...}`
to one call. See [Encrypted request bodies](https://developers.askparable.com/getting-started/encryption.md).

## Handle errors and retries

The client gives each request 30 seconds. Set `Timeout` in milliseconds in
`SDKConfig` to change it.

The client retries a request that gets `429` up to 3 times. It waits for the
seconds in the `Retry-After` header, or 1, 2, and 4 seconds when the header
is absent, and never more than 300 seconds. Set `MaxRateLimitRetries` in
`SDKConfig` to change the count. A pointer to `0` turns the retries off. The
client does not retry other failures.

Each failure is one of these error types:

| Type | When | Useful fields |
| - | - | - |
| `*webapisdk.APIError` | The API answered with an error status. | `StatusCode`, `Code`, `Message`, `RequestID`, `Details`, `ValidationErrors` |
| `*webapisdk.AuthenticationError` | `401`. It wraps an `*APIError`. | As `*APIError` |
| `*webapisdk.AuthorizationError` | `403`. It wraps an `*APIError`. | As `*APIError` |
| `*webapisdk.RateLimitError` | `429` after the retries. It wraps an `*APIError`. | `RetryAfter`, the seconds to wait, or `nil` |
| `*webapisdk.NetworkError` | No answer arrived, or the time limit ended the request. | `Message`, `Body` |
| `*webapisdk.ValidationError` | The input failed the client's checks. Nothing was sent. | `Errors` |

When the API refuses the input with `400`, `ValidationErrors` holds the
refused fields and the rule each one failed, in the same shape as the
`Errors` of a `*ValidationError`. It is `nil` when the answer names no field.

`errors.As` finds the `*APIError` inside a `401`, `403`, or `429` error. A
`*NetworkError` is not an `*APIError`, so check for it first:

```go theme={null}
me, err := sdk.UsersNamespace.Me(ctx)
var networkErr *webapisdk.NetworkError
var apiErr *webapisdk.APIError
switch {
case errors.As(err, &networkErr):
	log.Printf("no answer: %v", err)
case errors.As(err, &apiErr):
	log.Printf("status %d, code %s, request %s: %s", apiErr.StatusCode, apiErr.Code, apiErr.RequestID, apiErr.Message)
case err != nil:
	log.Print(err)
default:
	fmt.Println(me.Name)
}
```

> [!TIP]
>
> Each operation page in the [API reference](https://developers.askparable.com/api-reference/overview.md) shows
> the Go call for that operation, such as `sdk.UsersNamespace.Me(ctx)`.

For table data, use SQL. See [Parable Data Engine](https://developers.askparable.com/data.md).


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