Skip to main content

Form

The Defactor Postman Collection comprises a suite of pre-configured API requests designed for seamless integration into the Postman application, facilitating access to the services offered by the Defactor API.


Security Details

To secure the API access control, all requests are made through Hasura which provides secure GraphQL, and RESTful endpoints restricted by a role-based authorization system.

Those endpoints that return public data do not require authentication for use. Query type requests are opened under the guest role, while mutation type needs a token with user role.

For those that can modify data the API expects a valid authorization header containing a bearer token. These tokens are implemented as JSON Web Tokens (JWTs) issued by the server.

The security of the JWT is because it is signed by a secret key and has a configurable expiration time, which by default is 240 minutes.

Upon receiving a request, Hasura decodes and validates the JWT, which contains user account data, and their corresponding role. If the role lacks the necessary permissions or the token is invalid, expired or missing, the request is promptly rejected.

Form

Get form templates

Fetches all community templates and templates that were created by an user supplied in arguments.

HTTP Request Method: GET

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/get-metadata-templates

Request Body

{
"creator":"0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"myTemplates": [
{
"template_name": "Example template",
"description": "Description",
"id": "0401aba8..."
}
],
"community_templates": [
{
"template_name": "Example community template",
"description": "Description",
"id": "0401aba8..."
}
]
}

Get form template

Fetches the desired form template with all its fields.

HTTP Request Method: GET

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/get-metadata-template

Request Body

{
"uuid": "0401aba8..."
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"template": [
{
"metadata_template_fields": [
{
"id": "1a4ef2e3...",
"is_dynamic": false,
"is_required": true,
"is_tooltip": false,
"placeholder": "",
"position_in_metadata": 1,
"suffix": null,
"tooltip_text": "Autogenerated",
"field_type": "string",
"field_name": "Asset Title",
"field_length": "full"
}
],
"description": "description",
"template_name": "Example template"
}
]
}

Get asset by status

Fetches all assets created by a given address. The assets are divided based on their status and counted.

HTTP Request Method: GET

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/get-assets-by-status

Request Body

{
"creator":"0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"drafts": [],
"pending": [],
"in_verification": [],
"verified": [],
"mined": [
{
"id": "9839c4b5...",
"asset_name": "Asset 1",
"asset_type": "erc20",
"chain_id": 1,
"price": "1000",
"status": "mined",
"supply": "1000000000000000000000000",
"asset_icon": "icon.png",
"asset_symbol": "AS1",
"contract_address": "0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5"
}
],
"drafts_count": {
"aggregate": {
"count": 0
}
},
"pending_count": {
"aggregate": {
"count": 0
}
},
"in_verification_count": {
"aggregate": {
"count": 0
}
},
"verified_count": {
"aggregate": {
"count": 0
}
},
"mined_count": {
"aggregate": {
"count": 1
}
}
}

Get asset

Fetches a specific asset and all its details.

HTTP Request Method: GET

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/get-asset

Request Body

{
"uuid":"8e075898..."
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"global_asset": [
{
"id": "9839c4b5...",
"updated_at": "2024-09-12T08:21:21.922369+00:00",
"created_at": "2024-09-04T08:07:27.490199+00:00",
"status": "mined",
"asset_icon": "icon.png",
"asset_type": "erc20",
"price": "1000",
"supply": "1000000000000000000000000",
"description": "description",
"spf": "mySpf",
"chain_id": 1,
"asset_name": "Asset 1",
"asset_category": "realEstate",
"creator": "0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5",
"asset_symbol": "AS1",
"contract_address": "0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5"
}
]
}

Get global assets by status

Fetches all the assets and orders them based on their status. The query also returns amounts of assets with every status.

HTTP Request Method: GET

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/get-global-assets-by-status

Request Body

{}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"drafts": [
{
"id": "926336bb...",
"asset_name": "Asset 1",
"asset_type": "erc20",
"chain_id": 1,
"price": "3000000000",
"status": "draft",
"supply": "2000000",
"asset_icon": "icon.svg",
"contract_address": "0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5"
}
],
"pending": [],
"in_verification": [],
"verified": [],
"mined": [],
"drafts_count": {
"aggregate": {
"count": 1
}
},
"pending_count": {
"aggregate": {
"count": 0
}
},
"in_verification_count": {
"aggregate": {
"count": 0
}
},
"verified_count": {
"aggregate": {
"count": 0
}
},
"mined_count": {
"aggregate": {
"count": 0
}
}
}

Get form entry

Fetches form entry with all the fields associated.

HTTP Request Method: GET

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/get-metadata-entry

Request Body

{
"uuid":"7739a0e2..."
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"global_metadata_entry": [
{
"asset": {
"id": "9839c4b5..."
},
"id": "1e0494cc...",
"metadata_status": {
"name": "inVerification"
},
"status": "inVerification",
"metadata_entry_fields": [
{
"id": "41a64309...",
"value": "100",
"metadata_template_field": {
"tooltip_text": "Field 1",
"suffix": null,
"position_in_metadata": 1,
"placeholder": "",
"is_tooltip": false,
"is_required": true,
"is_dynamic": false,
"field_type": "string",
"field_name": "Details",
"field_length": "full"
}
}
]
}
]
}

Post form template

Posts a new instance of form template.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/post-metadata-template

Request Body

{
"creator": "0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5",
"description": "Short description",
"template_name": "My form",
"isCommunity": false,
"isDerived": false
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"insert_global_metadata_template": {
"returning": [
{
"id": "1731c298..."
}
]
}
}

Post form entry

Posts a new instance of form entry.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/post-metadata-entry

Request Body

{
"asset_id":"9839c4b5",
"metadata_id":"1731c298",
"creator":"0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5",
"status": "draft"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"insert_global_metadata_entry": {
"returning": [
{
"id": "086a5053..."
}
]
}
}

Post form template field

Posts a new template field associated with a form template.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/post-metadata-template-field

Request Body

{
"field_length":"full",
"field_name":"Name",
"field_type":"number",
"is_dynamic":true,
"is_required":true,
"is_tooltip":true,
"metadata_id":"bd04f5cc...",
"placeholder":"Field",
"position_in_metadata": 0,
"suffix":"usd",
"tooltip_text": ""
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"insert_global_metadata_template_field": {
"returning": [
{
"id": "4736e30e..."
}
]
}
}

Post form entry field

Post a field value for a form entry.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/post-metadata-entry-field

Request Body

{
"entry_metadata_id":"751d7024...",
"field_id":"853e6f1e...",
"value":"365"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"insert_global_metadata_entry_field": {
"returning": [
{
"id": "0488d838..."
}
]
}
}

Post asset link

Posts an url for an associated asset.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/post-asset-link

Request Body

{
"asset_id": "866cd4ff...",
"url":"https://someLink.com"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"insert_global_asset_link": {
"returning": [
{
"id": "73121cb7..."
}
]
}
}

Post asset

Posts a new instance of asset, associated with the entry form.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1post-asset

Request Body

{
"asset_type":"erc20",
"asset_icon":"/icon.svg",
"supply":"2000000",
"status":"draft",
"spf":"spf",
"price":"3000000000",
"description":"Description",
"chain_id": 1,
"asset_name":"Asset 1",
"asset_category":"realEstate",
"creator":"0xa8983Fe59b2F08F9F1B3E833c5D47B256F7FE0d5",
"asset_symbol": "AS1"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"insert_global_asset": {
"returning": [
{
"id": "0ef0b305-b193-4b81-9f1a-37567eb91edc"
}
]
}
}

Post form status update

Updates status of an entry form.

HTTP Request Method: POST

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/update-metadata-status

Request Body

{
"metadata_id": "bd04f5cc-b5d7-4675-a883-dca44a3320f7",
"newStatus": "pending"
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"update_global_metadata_entry": {
"returning": [
{
"id": "1e0494cc..."
}
]
}
}

Delete form template

Deletes an instance of form template.

Note: There should be no form entries associated with the template, otherwise deletion will not work.

HTTP Request Method: DELETE

Roles: User

Request URL: {{BASE_RESTFUL_URL}}/v1/delete-metadata-template

Request Body

{
"metadata_id": "bd04f5cc..."
}

Response

Upon successful completion of a request, the server will issue a status code of 200. Successful response should look like this:

{
"delete_global_metadata_template_field": {
"returning": [
{
"id": "4736e30e..."
}
]
},
"delete_global_metadata_template": {
"returning": [
{
"id": "1731c298..."
}
]
}
}

Follow us:

Copyright © 2024 Defactor. All Rights Reserved