Issuing is the process of awarding a badge to a specific earner. In BadgeKit API, issuing a badge means creating a badge instance. Note that when a review is submitted in which an earner application for a badge is approved, this does not mean that the badge is automatically issued. Issuer sites must use the below API endpoints to issue badges, marking any relevant applications as processed when this occurs. These endpoints also apply to badges issued without the assessment process, for example badges issued directly to earner email addresses or using claim codes.
NAME | VALUE |
---|---|
slug |
string |
email |
email address - earner email |
expires |
timestamp - optional expiry date |
issuedOn |
timestamp - API will generate |
claimCode |
claim code - if badge is issued using claim code |
assertionUrl |
url - location of issued badge assertion, generated by API |
badge |
badge - API endpoints return badge issued along with instances |
- Retrieve Badge Instances
GET /systems/:slug/badges/:slug/instances
GET /systems/:slug/issuers/:slug/badges/:slug/instances
GET /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances
- Retrieve a Specific Instance
GET /systems/:slug/instances/:email
GET /systems/:slug/issuers/:slug/instances/:email
GET /systems/:slug/issuers/:slug/programs/:slug/instances/:email
GET /systems/:slug/badges/:slug/instances/:email
GET /systems/:slug/issuers/:slug/badges/:slug/instances/:email
GET /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances/:email
- Create a Badge Instance
POST /systems/:slug/badges/:slug/instances
POST /systems/:slug/issuers/:slug/badges/:slug/instances
POST /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances
- Delete an Instance
DELETE /systems/:slug/badges/:slug/instances/:email
DELETE /systems/:slug/issuers/:slug/badges/:slug/instances/:email
DELETE /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances/:email
Retrieves all instances for a specific badge within a system, issuer or program.
GET /systems/:slug/badges/:slug/instances
GET /systems/:slug/issuers/:slug/badges/:slug/instances
GET /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances
page
: - page of results to returncount
: - count of results to return per page
e.g. /systems/<slug>/badges/<slug>/instances?count=2&page=1
HTTP/1.1 200 OK
Content-Type: application/json
{
"instances": [
{
"slug": "instance-slug",
"email": "[email protected]",
"expires": "2014-10-29T10:16:01.000Z",
"issuedOn": "2014-05-29T10:16:01.000Z",
"claimCode": "claim-code",
"assertionUrl": "http://issuersite.com/public/assertions/instance-slug",
"badge": {
"id": 1,
"slug": "badge-slug",
...
}
},
...
],
"pageData": {
"page": 1,
"count": 2,
"total": 4
}
}
pageData
is returned when pagination parameters are used.
- instances
[ ]
- slug
- expires
- issuedOn
- claimCode
- assertionUrl
- badge
None
Retrieve a specific instance of a badge.
GET /systems/:slug/instances/:email
GET /systems/:slug/issuers/:slug/instances/:email
GET /systems/:slug/issuers/:slug/programs/:slug/instances/:email
GET /systems/:slug/badges/:slug/instances/:email
GET /systems/:slug/issuers/:slug/badges/:slug/instances/:email
GET /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances/:email
You can retrieve instances of badges awarded to a particular email address, for systems, issuers, programs and badges.
HTTP/1.1 200 OK
Content-Type: application/json
{
"instance":
{
"slug": "instance-slug",
"email": "[email protected]",
"expires": "2014-10-29T10:16:01.000Z",
"issuedOn": "2014-05-29T10:16:01.000Z",
"claimCode": "claim-code",
"assertionUrl": "http://issuersite.com/public/assertions/instance-slug",
"badge": {
"id": 1,
"slug": "badge-slug",
...
}
}
}
- instance
- slug
- expires
- issuedOn
- claimCode
- assertionUrl
- badge
- Instance not found
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"code": "ResourceNotFound",
"message": "Could not find badgeInstance field: `email`, value: <attempted-email>"
}
To actually issue (or "award") a badge to an earner in BadgeKit API, you create a badge instance. A badge instance is an awarded badge, issued to a specific earner.
POST /systems/:slug/badges/:slug/instances
POST /systems/:slug/issuers/:slug/badges/:slug/instances
POST /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances
Requests can be sent as application/json
, application/x-www-form-urlencoded
or multipart/form-data
.
Parameters | Required | Description |
---|---|---|
required | The email address for the earner the badge is being issued to. | |
claimCode | optional | A claim code for the badge. |
slug | optional | Instance slug. (API will generate if not provided.) |
issuedOn | optional | Timestamp representing date issued. (API will generate if not provided.) |
expires | optional | Timestamp representing date instance expires. |
HTTP/1.1 201 Created
Content-Type: application/json
{
"status": "created",
"instance": {
"slug": "abcdefghi123456789abcdefghi123456789",
"email": "[email protected]",
"expires": null,
"issuedOn": "2014-05-29T10:16:01.654Z",
"claimCode": "abcde12345",
"assertionUrl": "http://issuersite.com/public/assertions/abcdefghi123456789abcdefghi123456789",
"badge": null
}
}
The assertion URL represents the location of the badge assertion. A badge assertion contains the details of an issued badge. See the latest assertion specification for more information. Claim code is only returned if the badge instance was created using a claim code.
- status
- instance
- slug
- expires
- issuedOn
- claimCode
- assertionUrl
- badge
- Invalid data
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"code": "ValidationError",
"message": "Could not validate required fields",
"details": [
{
"field": "email",
"value": "..."
},
...
]
}
- Duplicate entry
HTTP/1.1 409 Conflict
Content-Type: application/json
{
"code": "ResourceConflict",
"message": "User <email> has already been awarded badge <badge-slug>",
"details": {
"assertionUrl": "http://issuersite.com/public/assertions/abcde..."
...
}
}
Delete a badge instance within a system, issuer or program context.
DELETE /systems/:slug/badges/:slug/instances/:email
DELETE /systems/:slug/issuers/:slug/badges/:slug/instances/:email
DELETE /systems/:slug/issuers/:slug/programs/:slug/badges/:slug/instances/:email
HTTP/1.1 200 OK
Content-Type: application/json
{
"instance": {
"slug": "abcdefghi123456789abcdefghi123456789",
"email": "[email protected]",
"expires": null,
"issuedOn": "2014-05-29T10:16:01.654Z",
"claimCode": "abcde12345",
"assertionUrl": "http://issuersite.com/public/assertions/abcdefghi123456789abcdefghi123456789",
"badge": {
...
}
}
}
- instance
- slug
- expires
- issuedOn
- claimCode
- assertionUrl
- badge
- Instance not found
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"code": "ResourceNotFound",
"message": "Could not find badgeInstance field: `email`, value: <attempted-email>"
}