# Create a SPIFFE trust store (/docs/apis/management/trust-stores/CreateSpiffeTrustStore)

`POST /truststores/spiffe`

Creates a new SPIFFE trust store for a federated SPIFFE trust domain and its workload identities.

Base URL: `https://{tenant}.{region}.monocloud.com/api`, where `{tenant}`, `{region}` (one of us, eu, in) come from your tenant. Authentication: send your Management API key in the `X-API-KEY` header.

## Request body

JSON, required. The request payload used to create a trust store.

- `show_in_discovery_document` (boolean, default false) Specifies whether this trust store’s mTLS endpoint aliases are published under `mtls_additional_endpoint_aliases` in the OpenID Connect discovery document.
- `options` (CreateSpiffeTrustStoreOptionsRequest, required) Trust store validation settings (certificate type, revocation, caching, and related policies).
  - `validate_certificate_use` (boolean, default true) Indicates whether the client certificate is validated for client authentication, including Client Authentication EKU checks across the certificate chain.
  - `validate_validity_period` (boolean, default true) Indicates whether the certificate validity period (`NotBefore` / `NotAfter`) is enforced.
  - `certificate_auth_cache_duration` (integer, int32, default 300) Specifies how long certificate authentication results are cached (in seconds).
  - `bundle_fetch_timeout` (integer, int32, default 10) Specifies the timeout for downloading the SPIFFE bundle from the bundle endpoint (in seconds).
- `spiffe_bundle_endpoint` (string, required, uri) The SPIFFE bundle endpoint URL used to retrieve trust domain signing keys.

## Response body

`201`, JSON. The trust store was created successfully

Returns `SpiffeTrustStore`.

- `id` (string, required) The unique identifier of the trust store.
- `name` (string, required) Human-readable name for the trust store.
- `enabled` (boolean, required) Indicates whether the trust store is enabled.
- `is_default` (boolean, required) Indicates whether this trust store is configured as the default store for the mTLS endpoint.
- `show_in_discovery_document` (boolean, required) Specifies whether this trust store’s mTLS endpoint aliases are published under `mtls_additional_endpoint_aliases` in the OpenID Connect discovery document.
- `options` (SpiffeTrustStoreOptions, required) Trust store validation settings (certificate type, revocation, caching, and related policies).
  - `validate_certificate_use` (boolean, required) Indicates whether the client certificate is validated for client authentication, including Client Authentication EKU checks across the certificate chain.
  - `validate_validity_period` (boolean, required) Indicates whether the certificate validity period (`NotBefore` / `NotAfter`) is enforced.
  - `certificate_auth_cache_duration` (integer, required, int32) Specifies how long certificate authentication results are cached (in seconds).
  - `bundle_fetch_timeout` (integer, required, int32) Specifies the timeout for downloading the SPIFFE bundle from the bundle endpoint (in seconds).
- `creation_time` (integer, required, date-time) Specifies the creation time of the trust store (in Epoch).
- `last_updated` (integer, required, date-time) Specifies the last update time of the trust store (in Epoch).
- `spiffe_bundle_endpoint` (string, required) The SPIFFE bundle endpoint URL used to retrieve trust domain signing keys.

## Errors

- `400` Bad Request
  - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
  - `title` (string, required) A short, human-readable summary of the error.
  - `status` (integer, required, int32) The HTTP status code associated with this error response.
  - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
  - `detail` (string) A human-readable explanation specific to this occurrence of the error.
  - `instance` (string) A URI reference that identifies the specific occurrence of the error.
- `401` Unauthorized
- `402` Payment Required
  Same body as `400`.
- `403` Forbidden
- `422` Unprocessable Entity
  - `type` (string, required) A URI reference that identifies the error type. When accessed, it may provide human-readable documentation.
  - `title` (string, required) A short, human-readable summary of the error.
  - `status` (integer, required, int32) The HTTP status code associated with this error response.
  - `trace_id` (string, required) A unique identifier for the request, used for tracing and diagnostics.
  - `detail` (string) A human-readable explanation specific to this occurrence of the error.
  - `instance` (string) A URI reference that identifies the specific occurrence of the error.
  - `errors` (Record<string, string[]>, required) A key-value map of validation errors, where each key represents a request field and the value contains one or more messages describing why the request could not be processed.

## Example (MonoCloud .NET SDK)

```csharp
using MonoCloud.Management;
using MonoCloud.Management.Models;
using MonoCloud.Management.Core.Base;

var apiClient = new MonoCloudManagementClient(new MonoCloudConfig("<your-domain>", "[[API-Key]]"));


var requestBody = new CreateSpiffeTrustStoreRequest
  {
    ShowInDiscoveryDocument = true,
    Options = new CreateSpiffeTrustStoreOptionsRequest
    {
      ValidateCertificateUse = true,
      ValidateValidityPeriod = true,
      CertificateAuthCacheDuration = 300,
      BundleFetchTimeout = 10,
    },
    SpiffeBundleEndpoint = "https://example.org/bundle.json",
  };


var result = await apiClient.TrustStores.CreateSpiffeTrustStoreAsync(requestBody);
```

## Example (MonoCloud Javascript SDK)

```javascript
import { MonoCloudManagementClient } from '@monocloud/management';

const apiClient = MonoCloudManagementClient.init({ domain: '<your-domain>', apiKey: '[[API-Key]]' });

const requestBody = {
  show_in_discovery_document: true,
  options: {
    validate_certificate_use: true,
    validate_validity_period: true,
    certificate_auth_cache_duration: 300,
    bundle_fetch_timeout: 10
  },
  spiffe_bundle_endpoint: 'https://example.org/bundle.json'
};

const result = apiClient.trustStores.createSpiffeTrustStore(requestBody);
```