Home /  Stash / 

curl/Postman Example

Example

This example highlights the common operations for the Stash service using curl. These examples can also easily be imported into Postman.

Authentication

Ensure that you have created a Stedi API Key. If using curl, you can export this API key in the STEDI_API_KEY environment variable. If using Postman, the API key can be configured under the "Authorization" header with Type set to API Key, Key set to Authorization and Value set to Key <your-stedi-api-key>.

Creating a Keyspace

In order to store keys and values, we need to create a Keyspace. We may use a single Keyspace for different situations, as long as we ensure that the keys will not overwrite one another.

curl --request POST 'https://stash.us.stedi.com/2022-04-20/CreateKeyspace' \
    --header "Authorization: Key ${STEDI_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "keyspaceName": "my-keyspace"
    }'
Note: It may take a few seconds for a Keyspace to be ready to use. You can use the /GetKeyspace operation to determine if it is in the ACTIVE state.

Storing Values

This snippet just stores a simple item where the Key is foo and the Value is bar. Note how we use the same Keyspace name as used in the previous step.
curl --request POST 'https://stash.us.stedi.com/2022-04-20/SetValue' \
    --header "Authorization: Key ${STEDI_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "keyspaceName": "my-keyspace",
        "key": "foo",
        "value": "bar"
    }'

Retrieving Values

Simply use the GetValue operation to retrieve any values.
curl --request POST 'https://stash.us.stedi.com/2022-04-20/GetValue' \
    --header "Authorization: Key ${STEDI_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "keyspaceName": "my-keyspace",
        "key": "foo"
    }'

Atomically increment a number

The IncrementValue operation will atomically increment a number by the amount specified. If the key does not exist, it will be initialized with 0. If the key exists and is not a number, this results in a ValidationError error.
curl --request POST 'https://stash.us.stedi.com/2022-04-20/IncrementValue' \
    --header "Authorization: Key ${STEDI_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "keyspaceName": "my-keyspace",
        "key": "increasing-number",
        "amount": 1
    }'

Feedback

Have an idea for something we could improve? Page not clear? We love feedback - send us a message.

Stedi

Build EDI integrations fast, without being an EDI expert

Start building
About
ProductPricingCareersContactBlog
Follow
  1. Twitter
  2. GitHub
Backed by
AdditionBloomberg BetaFirst RoundStripeUSV
Customer AgreementService TermsPrivacy Notice

Stedi is a registered trademark of Stedi, Inc. All names, logos, and brands of third parties listed on our site are trademarks of their respective owners (including “X12”, which is a trademark of X12 Incorporated). Stedi, Inc. and its products and services are not endorsed by, sponsored by, or affiliated with these third parties. Our use of these names, logos, and brands is for identification purposes only, and does not imply any such endorsement, sponsorship, or affiliation.