> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/go-sdk/v2/samples/consumption-license.md).

# Consumption License

Licenses of type **consumption** allow you to use a limited or unlimited number of consumable units, which can be applied based on your application’s needs. For example,

Our SDK provides a simple two-step process for managing consumptions:

{% stepper %}
{% step %}

### Local Consumption

You update the locally stored license file to reflect usage, without communicating with the server yet.
{% endstep %}

{% step %}

### Sync with Server

You synchronize the updated license state with the LicenseSpring cloud server. At this stage, the actual consumption is registered on the server and reflected on the platform.
{% endstep %}
{% endstepper %}

### UpdateConsumption

This method updates the `LocalConsumptions` value in the local license file, if the value alligns with license's specifications.

{% code title="example.go" %}

```go
	ld, err = lh.UpdateConsumption(1)

	t := ld.TotalConsumptions
	l := ld.LocalConsumptions
	fmt.Printf("Total Consumptions: %d\n  Local Consumptions: %d\n", t, l)
```

{% endcode %}

### SyncConsumption

This method synchronizes the current `LocalConsumptions` value with the LicenseSpring cloud server. If the sync is successful and no errors are returned, the local license file is updated as follows:

* `TotalConsumptions` is incremented (or decremented) based on the local value.
* `LocalConsumptions` is reset to zero.

This update will also be visible on the LicenseSpring platform dashboard.

`SyncConsumption` also can request the server to allow overages. The second argument is whether to ask for overages and the third is the number of overages requested, if any.

If overages requested, the change will be reflected both in local license file and platform.

{% code title="example\_sync.go" %}

```go
	ld, err = lh.SyncConsumption(ctx, false, 0)

	t := ld.TotalConsumptions
	l := ld.LocalConsumptions
	fmt.Printf("Total Consumptions: %d\n  Local Consumptions: %d\n", t, l)
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.licensespring.com/sdks/go-sdk/v2/samples/consumption-license.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
