# Create a DID-Linked Resource

Using the `/resource/create` API, users are able to create **custom DID-Linked Resources**, including:

1. Schemas
2. Credential Definitions
3. Trust Registries
4. Status Lists
5. Logos associated with DIDs
6. Governance files

## Step 1: Set up your account

Make sure you have set up your account with cheqd Studio and are logged in, using our guide below:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><mark style="color:blue;"><strong>Set up your account</strong></mark></td><td>Set up your account with cheqd Studio and log in to start using the APIs.</td><td><a href="../../getting-started/studio/set-up-account">set-up-account</a></td></tr></tbody></table>

## Step 2: Create a DID

Before you can create a DID-Linked Resource, you need to create a ***"parent"*** DID which is used to link the Resource on-ledger. Use the API in the page below to create a DID:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><mark style="color:blue;"><strong>Create an Issuer DID</strong></mark></td><td>Create a W3C conformant DID on cheqd using the <code>did:cheqd</code> DID Method.</td><td><a href="../dids/create-did">create-did</a></td></tr><tr><td><mark style="color:blue;"><strong>Learn more about DID-Linked Resources</strong></mark></td><td>Understand the context and technical composition of cheqd's DID-Linked Resources.</td><td><a href="understanding-dlrs">understanding-dlrs</a></td></tr></tbody></table>

## Step 3. Create your Resource content and save the file locally

DID-Linked Resources can be any type of file or content that is **below \~45kb in size**.

For the purpose of an example, lets use an AnonCreds schema (JSON file) as the resource:

```json
{
  "name": "degreeSchema",
  "version": "1.5.7",
  "attrNames": ["name", "age", "degree", "grade"]
 }
```

Save this file locally and call it something like `resource.json.`

## Step 4: Encode the file

Prepare a file with resource and encode it into `base64, base64url` or `hex`. On Unix systems, you can use the following command input:

```bash
$ base64 -w 0 resource.json
<path-to-the-resource-file>
```

Expected output:

```bash
$ base64 -w 0 resource.json
SGVsbG8sIHdvcmxk
```

## Step 5: Set a consistent name and type

Resources are grouped by having identical **names** and **types**. This means if you want to create a new version of the same Resource, you will need to **specify the same name and type in the following request**.&#x20;

## Step 6: Populate the request inputs and hit the API

## Create a DID-Linked Resource.

> This endpoint creates a DID-Linked Resource. As input, it can take the DID identifier and the resource parameters via a form, or the fully-assembled resource itself.

```json
{"openapi":"3.0.0","info":{"title":"cheqd Studio API for cheqd network","version":"2.0.0"},"tags":[{"name":"DID-Linked Resources (DLRs)"}],"servers":[{"url":"https://studio-api.cheqd.net","description":"Main (production) server"},{"url":"https://studio-api-staging.cheqd.net","description":"Staging server for testing"},{"url":"http://localhost:3000","description":"Local server for testing"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"x-api-key","in":"header"}},"schemas":{"CreateResourceRequest":{"description":"Input fields for DID-Linked Resource creation.","type":"object","additionalProperties":false,"required":["name","type","data","encoding"],"properties":{"data":{"description":"Encoded string containing the data to be stored in the DID-Linked Resource.","type":"string"},"encoding":{"description":"Encoding format used to encode the data.","type":"string","enum":["base64url","base64","hex"]},"name":{"description":"Name of DID-Linked Resource.","type":"string"},"type":{"description":"Type of DID-Linked Resource. This is NOT the same as the media type, which is calculated automatically ledger-side.","type":"string"},"alsoKnownAs":{"description":"Optional field to assign a set of alternative URIs where the DID-Linked Resource can be fetched from.","type":"array","items":{"type":"object","properties":{"uri":{"type":"string"},"description":{"type":"string"}}}},"version":{"description":"Optional field to assign a human-readable version in the DID-Linked Resource.","type":"string"},"publicKeyHexs":{"description":"List of key references (publicKeys) which will be used for signing the message. The should be in hexadecimal format and placed in the wallet of current user.","type":"array","items":{"type":"string"}}}},"ResourceMetadata":{"type":"object","properties":{"resourceURI":{"type":"string"},"resourceCollectionId":{"type":"string"},"resourceId":{"type":"string"},"resourceName":{"type":"string"},"resourceType":{"type":"string"},"mediaType":{"type":"string"},"resourceVersion":{"type":"string"},"checksum":{"type":"string"},"created":{"type":"string"},"nextVersionId":{"type":"string"},"previousVersionId":{"type":"string"}}},"InvalidRequest":{"description":"A problem with the input fields has occurred. Additional state information plus metadata may be available in the response body.","type":"object","properties":{"error":{"type":"string"}}},"UnauthorizedError":{"description":"Access token is missing or invalid","type":"object","properties":{"error":{"type":"string"}}},"InternalError":{"description":"An internal error has occurred. Additional state information plus metadata may be available in the response body.","type":"object","properties":{"error":{"type":"string"}}}}},"paths":{"/resource/create/{did}":{"post":{"tags":["DID-Linked Resources (DLRs)"],"summary":"Create a DID-Linked Resource.","description":"This endpoint creates a DID-Linked Resource. As input, it can take the DID identifier and the resource parameters via a form, or the fully-assembled resource itself.","parameters":[{"in":"path","name":"did","description":"DID identifier to link the resource to.","schema":{"type":"string"},"required":true}],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/CreateResourceRequest"}},"application/json":{"schema":{"$ref":"#/components/schemas/CreateResourceRequest"}}}},"responses":{"200":{"description":"The request was successful.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResourceMetadata"}}}},"400":{"$ref":"#/components/schemas/InvalidRequest"},"401":{"$ref":"#/components/schemas/UnauthorizedError"},"500":{"$ref":"#/components/schemas/InternalError"}}}}}}
```
