Last Modified October 7, 2021

Credits Consume

  1. API Request
  2. API Response
  3. Request Examples
  4. Response Examples

 

Use the Credits Consume API to Consume a Credit for a given License Code or Buyer Email.

HTTP Verb Element Syntax
POST URL https://api.softworkz.com/v1/Credits/<productId>/<licenseId>/consume
Body
{
    "Name":"<creditName>",
    "Count":"<Count>",
    "Target":"<target>",
    "UserIp":"<userIp>"
    "Test":"<test>",
    "SendDnaEmail":"<SendDnaEmail>",
}
                                    

Consume the <Count> of the Credit type <Name> associated with the <Target> and return the updated status of the Credit

Possible Targets:

  • LICENSE - applies to credits associated with the License Code
  • EMAIL - applies to credits associated with the Buyer Email of this License Code
  • ALL - applies to credits associated with both the License Code and the Buyer Email.

For the target ALL, will decrement the credits of the License Code first, and if not enough, will then decrement the credits of the Buyer Email

You must provide the End User IP Address in the body of the Request.

The IP Address is used to protect your implementation and this API from abuse and is only used to manage the IP Lockout feature of this API. The IP Lockout will be triggered after multiple invalid attempts in a given period, and a set cooling period will be enacted. Both are system-wide settings.

Where:

Parameter Type Value Required Default
<productId> string the DNA ProductID Yes  
<licenseId> string the License Activation Code Yes  
<name> string the Credit type <Name> to consume Yes  
<count> integer the <count> of credits, from 0 to 20,000 Yes  
<target> string LICENSE  or  EMAIL  or  ALL Yes  
<userIp> string the User's IP Address, for protection against end-user abuse Yes  
<Test> bool if true, this is a Test Event No false
<SendDnaEmail> bool if true, software_DNA will send Custom Emails to the old and new Email addresses to notify User of the change to the License Email No true

The Credit Consume API returns the updated status of the Credit in JSON format:

{
  "Name": "<creditName>",
  "Count": "<updatedCount>"
}
                

 

API Response

Success HTTP Status Code Description
200 OK Credit Status JSON string is returned in Response
Error HTTP Status Code Description
400 Bad Request one of the parameters was invalid or missing - check error message in Response for details
401 Unauthorized Basic Authentication failed - verify that you are using the correct <clientId> and <apiKey> information in the Basic Authentication Header
403 Forbidden The <Target> did not have sufficient Credits
404 Not Found The <productId> and/or the <licenseId> was not found
429 Too Many Requests You have exceeded the allowed maximum of API Requests in the period - check "X-RateLimit-Reset" for the number of seconds remaining before reset
500 Internal Error An error occured on the DNA Server - try again later. Tech Support has been notified

 

Examples of API Requests

POST Credit Consume example - returns updated count of the Credit

curl -v -X POST https://api.softworkz.com/v1/credits/<productId>/TEST12345/consume
-H "Accept: application/json"
-u "<clientId>:<API Key>"
-d ’{"Name":"Reports","Count":1,"Target":"LICENSE","UserIp":"0.0.0.0"}’
                

 

Example of API Response with Credits Consume

{
  "Name": "Reports",
  "Count": 10
}
                

 

Example of API Error Response

{
  "Message": "Invalid ProductId format"
}