Get company subscriptions#

This endpoint is used to get all your company subscriptions.

Endpoint steps#

  1. Get a token from your credentials by calling the endpoint Account/getToken;

  2. Get all your subscriptions calling the endpoint Subscriptions/clientId/{companyVatNumber} from WebStore API URL;

Response structure from server#

When a request is well formed and the authentication data is correct the system responds with a message envelope as follows:

{
	"CorrelationId": "<GUID>", /* for correlation purposes */
	"IsValid": true,           /* false in case of erros */
	"Errors": [],              /* if empty is a good signal */
	"Data": "<Service Response Data>"   /* the data retuned ex: token, invoice status, dependent on the endpoint called */
}

Endpoint Server Base URL#

# SANDBOX - Test Environment
webstore_server_base_adress = "dcn-solution.saphety.com/Dcn.Sandbox.WebApi"

# Saphety Invoice Network - Production Environment
#webstore_server_base_adress = "dcn-solution.saphety.com/IN2.WebStore.WebApi"

1. Get a token (Account/getToken)#

Get a token from your account credentials using endpoint api/Account/getToken
Check here how to obtain an authentication token.

2. Get Subscriptions (Subscriptions/clientId/{companyVatNumber})#

2.1 Request structure#

In the endpoint url you need to supply your Company VAT Number.

companyVatNumber#

  • Description: Tax identification of the entity (aka as vatNumber).

  • Required: Yes

  • Type: string

  • Example: “PT518576302”

  • Notes: Only accepts valid vatNumbers and filled with the countryCode prefix.

2.2 Request example#

# WebStore endpoint url for retrieving information
service_url = "https://" + webstore_server_base_adress + "/api/Subscriptions/clientId/" + "PT240606590"
print (service_url)
https://dcn-solution.saphety.com/Dcn.Sandbox.WebApi/api/Subscriptions/clientId/PT240606590

2.3 Call the endpoint to get your company subscriptions#

headers = {
    'Authorization': 'bearer ' + token
}
response = requests.request("GET", service_url, headers=headers)

# formating the response to json for visualization purposes only
json_response = json.loads(response.text)
print(json.dumps(json_response["Data"], indent=4))
[
    {
        "Id": "ad152107-78f6-4d07-9e87-b130bbee296c",
        "PlanId": null,
        "CustomPlanId": "1b60cf5d-921b-47b3-94c7-f98008ca5528",
        "ClientId": "PT240606590",
        "ApplicationCode": "DcnSolution",
        "ValidFrom": "2023-01-05T00:00:00",
        "ValidTo": "2023-03-05T00:00:00",
        "LastRenewalDate": "2023-01-05T00:00:00",
        "Status": "NotRenewable",
        "CreationDate": "2023-01-05T17:44:07.3133333"
    }
]

The properties “PlanId” and “CustomPlanId” defines when the subscription is a normal subcription or a custom subscription.
Only one field will be filled in.
You can also check the validation period of the subscription, checking the initial date (ValidFrom) and the final date (ValidTo).

Possible values for Status:

  • Active

  • Inactive

  • DoNotRenew

  • NotRenewable

  • Standby

See here how to get the plan information.
See here how to get the custom plan information.
See here how to get the subscription features (plan consume).