---
title: "Exporting a Security Object"
slug: "dsm-example-code-exporting-a-security-object"
updated: 2024-12-10T17:40:15Z
published: 2024-12-10T17:40:15Z
canonical: "support.fortanix.com/dsm-example-code-exporting-a-security-object"
---

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

# Exporting a Security Object

Security Objects need to be marked as **exportable** for this operation, which means that **EXPORT** operation needs to be enabled in Key Operations of the Security-object.

- [C#](/docs/dsm-example-code-exporting-a-security-object#tabs-1)
- [Go](/docs/dsm-example-code-exporting-a-security-object#tabs-2)
- [Java](/docs/dsm-example-code-exporting-a-security-object#tabs-3)
- [Python](/docs/dsm-example-code-exporting-a-security-object#tabs-4)
- [PHP](/docs/dsm-example-code-exporting-a-security-object#tabs-5)
- [Javascript](/docs/dsm-example-code-exporting-a-security-object#tabs-6)
- [REST API using curl](/docs/dsm-example-code-exporting-a-security-object#tabs-7)

### C#

```bash
SobjectDescriptor soDescriptor = new SobjectDescriptor(
            Name: (<name of the key>);
KeyObject keyObject = securityObjectsApi.GetSecurityObjectValue (soDescriptor);
keyObject.Value // contains the key material
```

### Go

```bash
keyName := "<name of the key>"
sobject, err := client.ExportSobject(ctx, sdkms.SobjectByName(keyName))
```

### Java

```bash
SobjectDescriptor soDescriptor = new SobjectDescriptor()
            .name(<name of the key>);
KeyObject keyObject = securityObjectsApi.getSecurityObjectValue (soDescriptor);
keyObject.value // contains the key material
```

### Python

```bash
api_instance = sdkms.v1.SecurityObjectsApi(api_client=client)
request = sdkms.v1.SobjectDescriptor(name='<name of the key>')
key = api_instance.get_security_object_value(request)
key.value #contains the key material
```

### PHP

```bash
$api_instance = new SdkmsClient\Api\SecurityObjectsApi($client);
$request=array('name' => '<name of the key>');
$keyObject = api_instance->getSecurityObjectValueEx($request);
$keyObject.value // contains the key material
```

### Javascript

```bash
var request = FortanixSdkmsRestApi.SobjectDescriptor.constructFromObject({"name": "<name of the key>"});
var exportCallback = function(error, data, response) {
    if (error) {
        console.error("Error: " + JSON.stringify(response));
    } else {
        data.value // contains the key material
    }
};
var sObjectsApi = new FortanixSdkmsRestApi.SecurityObjectsApi()
sObjectsApi.getSecurityObjectValueEx(request, exportCallback);
```

### REST API using curl

```bash
curl <Endpoint URL>/crypto/v1/keys/export -H 'Authorization: Bearer YhXwwa-6C...ig5g' -d '{"name": "Key-Name"}'
```

A security object is any datum stored in DSM (for example a key, a certificate, a password, or other security objects). Each security object is assigned to exactly one group. users and applications assigned to the group have permission to see the security object and to perform operations on it.

## Related

- [SDKs for REST API](/fortanix-dsm-clients-sdks-for-rest-api.md)
- [Signature Generation](/dsm-example-code-signature-generation.md)
- [App Authentication with an API Key](/dsm-example-code-app-authentication-with-an-api-key.md)
- [User Authentication](/dsm-example-code-user-authentication.md)
- [Command-Line Interface (CLI) for Fortanix DSM (sdkms-cli)](/fortanix-dsm-clients-command-line-interface-cli.md)
