Delivery through REST (POST)

Delivery - REST

Delivery - REST

This URL will be called when the build completes.

When the exporter runs (either successfully or with a potential error), your API will be invoked and sent the following JSON payload through POST:


                                                        
                                                        
                                                            {
                                                          "event": "job:updated",
                                                          "workspace": {
                                                            "id": "1",
                                                            "name": "Example workspace"
                                                          },
                                                          "designSystem": {
                                                            "id": "2",
                                                            "name": "Example Design System"
                                                          },
                                                          "designSystemVersion": {
                                                            "id": "3",
                                                            "name": "A version name",
                                                            "version": "v0.1"
                                                          },
                                                          "exporter": {
                                                            "id": "4",
                                                            "name": "Example exporter"
                                                          },
                                                          "hook": {
                                                            "id": "5",
                                                            "name": "Example hook"
                                                          },
                                                          "job": {
                                                            "id": "6",
                                                            "status": "Success",
                                                            "logsUrl": "https://api.supernova.io/api/codegen/workspaces/1/jobs/6/logs",
                                                            "s3": {
                                                              "url": "https://api.supernova.io/api/codegen/workspaces/1/jobs/6/result",
                                                            }
                                                        
                                                            

There are several important pieces to this payload:

Hook Configuration

You will get a complete set of the configuration attributes inside the payload, allowing you to precisely identify which event happened, in which design system, and forward the code wherever you want to.

Job

Job describes the result of the run:

  • id uniquely identifies the job / exporter run inside your workspace
  • status results either to Success or Failure
  • logsUrl gives you a full log of exporter runs. You need request this endpoint using your PAT.

URLs

If the exporter created code successfully, url will be provided as well.

The URL links to a secure, signed .zip file containing the structured output of the exporter. To access this URL, you'll need to generate a PAT on the Authentication page and then use it with the returned URL.

This is an example with curl library:


                                                        
                                                        
                                                            curl --location 'https://api.supernova.io/api/codegen/workspaces/{{wId}}/jobs/{{jobId}}/result' \
                                                        --header 'Authorization: Bearer {{PAT}}' \
                                                        --output {{saveFilePath}}
                                                        
                                                            

And an example for Node.js:


                                                        
                                                        
                                                            var request = require('request');
                                                        var options = {
                                                          'method': 'GET',
                                                          'url': 'https://api.supernova.io/api/codegen/workspaces/{{wId}}/jobs/{{jobId}}/result',
                                                          'headers': {
                                                            'Authorization': 'Bearer {{PAT}}'
                                                          }
                                                        };
                                                        request(options, function (error, response) {
                                                          if (error) throw new Error(error);
                                                          console.log(response.body);
                                                        });