> For the complete documentation index, see [llms.txt](https://developers.os.university/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.os.university/api-reference/certificate.md).

# Certificate

## Certificate model fields

Certificate model in database contains next fields:

* Required:
  * `id` (uuid)
  * `holder` (ForeignKey to user, setting to Null, if user was deleted)
  * `user_eth_address` (CharField)
  * `institution_title` (CharField)
  * `institution_link` (URLField)
  * `certificate_title` (CharField)
  * `granted_to_type` (PositiveSmallIntegerField from 1 to 3)
  * `ipfs_hash` (CharField)
* Optional:
  * `program_title` (CharField)
  * `course_link` (URLField)
  * `industries` (ManyToManyField)
  * `skills` (ManyToManyField)
  * `score` (FloatField)
  * `duration` (PositiveSmallIntegerField)
  * `expiration_date` (DateTimeField)
  * `checksum_hash` (CharField)

## Certificate View Set

### Create new certificate

Method `create(self, request)` acccepting POST requests with JSON information about new certificate.

Certificate file previously should be uploaded on IPFS.

**Returns**

* If ok:
  * Code status 200
  * `certificate_pk` JSON with Certificate id on bdn
* Else:
  * Code status 400
  * `error` JSON with errors

**Example**:

```
// POST Request to *your_bdn_host*/api/v1/certificates/

'/api/v1/certificates/',
data={
    'institution_title': 'test',
    'institution_link': 'http://example.com',
    'certificate_title': 'test',
    'holder_eth_address': '0xD2BE64317Eb1832309DF8c8C18B09871809f3735',
    'score': '',
    'duration': '',
    'skills': ['Python'],
    'ipfs_hash': 'Qme1WcHcEZU5uct9Wgfdn7S3mKbjSkvwdDTTfSUDjHTqjL'
},
HTTP_AUTH_SIGNATURE='0xe646de646dde9cee6875e3845428ce6fc13d41086e8a7f6531d1d526598cc4104122e01c38255d1e1d595710986d193f52e3dbc47cb01cb554d8e4572d6920361c',
HTTP_AUTH_ETH_ADDRESS='D2BE64317Eb1832309DF8c8C18B09871809f3735'
```

### Get certificate info

Method `retrieve(self, request, pk=None)` acccepting GET requests with certificate id and reply with JSON information about certificate.

**Returns**

* If ok:
  * Code status 200
  * JSON with Certificate data

**Example**

```
// GET Request to *your_bdn_host*/api/v1/certificates/(?P<pk>[^/.]+)/

'/api/v1/certificates/e0e433e9-477e-43a3-8e23-dfe2686202be/',
HTTP_AUTH_SIGNATURE='0xe646de646dde9cee6875e3845428ce6fc13d41086e8a7f6531d1d526598cc4104122e01c38255d1e1d595710986d193f52e3dbc47cb01cb554d8e4572d6920361c',
HTTP_AUTH_ETH_ADDRESS='D2BE64317Eb1832309DF8c8C18B09871809f3735')
```

### Get certificate list

Method `list(self, request)` acccepting GET requests reply with JSON information about certificates by issuer user.

**Returns**

* If ok:
  * Code status 200
  * JSON with Certificates list data by issuer user

**Example**

```
// GET Request to *your_bdn_host*/api/v1/certificates/

'/api/v1/certificates/',
HTTP_AUTH_SIGNATURE='0xe646de646dde9cee6875e3845428ce6fc13d41086e8a7f6531d1d526598cc4104122e01c38255d1e1d595710986d193f52e3dbc47cb01cb554d8e4572d6920361c',
HTTP_AUTH_ETH_ADDRESS='D2BE64317Eb1832309DF8c8C18B09871809f3735'
```

### Get certificates by learner

Method `get_certificates_by_learner(self, request)` acccepting GET requests with `eth_address` and reply with JSON information about certificates by learner ETH Address.

**Returns**

* If ok:
  * Code status 200
  * JSON with Certificates list data by learner ETH Address

**Example**

```
// GET Request to *your_bdn_host*/api/v1/certificates/get_certificates_by_learner/?eth_address=*some_eth_address*

'/api/v1/certificates/?eth_address=0x00000',
HTTP_AUTH_SIGNATURE='0xe646de646dde9cee6875e3845428ce6fc13d41086e8a7f6531d1d526598cc4104122e01c38255d1e1d595710986d193f52e3dbc47cb01cb554d8e4572d6920361c',
HTTP_AUTH_ETH_ADDRESS='D2BE64317Eb1832309DF8c8C18B09871809f3735'
```

### Delete certificate by id

Method `delete_by_id(self, request, pk=None)` acccepting POST requests with certificate id in line.

**Returns**

* If ok:
  * Code status 200
* Else if user is not holder:
  * Code status 401
* Else if certificate does not exist:
  * Code status 404

**Example**:

```
// POST Request to *your_bdn_host*/api/v1/certificates/(?P<pk>[^/.]+)/delete_by_id/

'/api/v1/certificates/e0e433e9-477e-43a3-8e23-dfe2686202be/delete_by_id/',
data={
},
HTTP_AUTH_SIGNATURE='0xe646de646dde9cee6875e3845428ce6fc13d41086e8a7f6531d1d526598cc4104122e01c38255d1e1d595710986d193f52e3dbc47cb01cb554d8e4572d6920361c',
HTTP_AUTH_ETH_ADDRESS='D2BE64317Eb1832309DF8c8C18B09871809f3735'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.os.university/api-reference/certificate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
