Moment API Key

Modified on Fri, 23 Oct at 1:20 PM

With an API key, your own systems, scripts or integration partners can read and write data in Moment through Moment's REST API. Each key belongs to one user in Moment and has that user's permissions.


Before you start

Turn on API Access. Go to Setup → Settings → Integrations, click + Create integration and choose API Access (API tilgang).

  • Tick Enabled.
  • Choose who should be notified about the integration.
  • Save.

Price. Access to the API has a monthly cost. Normal use is included. Very many requests or very large amounts of data can be invoiced extra. See Cost below.

Choose the right user. A key gets exactly the same access as the user it is created for. We recommend this:

  • Use a dedicated user for the API, for example api@yourcompany.no, not a personal user who might leave the company. If the user is no longer employed, the key stops working.
  • The user must be active and licensed in Moment.
  • Give the user only the access it needs. The key works in every company the user has access to, including companies where the user is an external user.



Create an API key

  1. Go to Company → API keys (Firma → API-nøkler). This page is only shown when API Access is enabled, and you need administrator access.
  2. Click + Create key (+ Opprett nøkkel).
  3. Fill in:
Field (EN / NB)Description
Resource / RessursThe user the key belongs to. Only current employees are listed.
Environment / MiljøChoose Production or All. The Sandbox environment is no longer available.
TestCreates a test key that expires after 14 days. The expiry date is set automatically and can't be changed.
Expiry date / UtløpsdatoThe last date the key can be used. It must be in the future.
  1. Click Generate (Generer).
  2. Copy the key right away and store it somewhere safe, such as a password manager. Moment shows: "Note! Copy and save this API key, it cannot be retrieved again." If you lose the key, create a new one.

Notification. The recipients chosen in the API Access integration get an e-mail every time a key is created, changed or deleted.




Manage your keys

The list under Company → API keys shows each key's:

  • Resource
  • Environment
  • whether it is a Test key
  • Expiry date

Change the expiry date. Click the pencil icon. Test keys can't be changed.

Delete a key. Click the bin icon and confirm with "Are you sure you want to remove this API key?". The key is removed from the list.

If a key may have been exposed, for example sent by e-mail or published by mistake, contact Moment support right away.

When a key expires, Moment rejects it with 401 Unauthorized. Change the expiry date, or create a new key, before it runs out.




Use the API key

Authentication

Moment's API uses Basic authentication:

Value
Usernameapikey
Password(your actual API key)


In practice, every request gets this header:

Authorization: Basic <base64 of "apikey:YOUR_API_KEY">


Most tools do this for you. In Postman, for example, choose Authorization → Type: Basic Auth, enter apikey as Username, and the key as Password.

URL

https://app.moment.team/api/1.0/companies/{COMPANYCODE}/{ENDPOINT}
  • {COMPANYCODE} is your company code, which you find in the URL when you are logged in to Moment.
  • {ENDPOINT} is the data you want, for example customers, projects or timeRecords.

Example: list all customers.

GET https://app.moment.team/api/1.0/companies/{COMPANYCODE}/customers

Example with curl:

curl -u apikey:YOUR_API_KEY https://app.moment.team/api/1.0/companies/YOURCOMPANY/customers



API documentation

The endpoints are documented in Swagger at https://app.moment.team/api/1.0/docs/.

Standard operations. All data types follow the same pattern:

ActionRequest
CreatePOST /
Read oneGET /{id}
Read a listGET /
UpdatePUT or PATCH /{id}
DeleteDELETE /{id}
Several at once, in one transactionPOST /batch


Responses and errors

ResponseMeaning
200OK
401 UnauthorizedThe key is wrong, expired or deleted, or the username isn't apikey.
403 ForbiddenThe key works, but its user has no access to this company or this data. Check the user's permissions in Moment.
429 Too Many RequestsToo many requests in a short time. Wait and try again.

Changes can take a few minutes. A new key, a changed expiry date or a deleted key can take up to 5 minutes to take effect.


Limits

  • Rate limit: 120 requests per second per IP address, and 30 requests per second per key. Above this, the API answers 429.
  • Large lists: some lists return a limited number of records. The response then contains limitWasExceeded. Add noLimit=true to get more, up to a maximum of 30,000 records. If you need more than that, narrow your filter.

Tip: find the right request

The easiest way to find the request for some data is to open the report in Moment that shows that data. Then look in your browser's Developer tools, under Network → Fetch/XHR, at which API URL the page calls. Use the same URL and parameters with your API key.



Webhooks and the API

If you want to know when something changes in Moment, combine the API with webhooks. A webhook sends a short message with the ID of what changed, and you fetch the full data with the API key. See Webhooks.



Import key (Moment Importer)

Under Setup → Settings → Import key (Importnøkkel) you find a different kind of key. It isn't an API key for everyday use:

API keyImport key
PurposeIntegrations and your own systemsThe first import of data with Moment Importer
AccessThe chosen user's permissionsFull administrator access to the company
ValidityUntil the expiry date you choose2 days
Requires API AccessYesNo

Only use the import key when Moment support asks you to.



Cost

From Moment's price terms.

  • Monthly fee. API access has a monthly fee.
  • Number of keys included. You can create as many API keys as you have licensed users. Extra keys are invoiced according to the price list.
  • Test keys aren't invoiced, up to three per user. Additional test keys are invoiced as ordinary keys.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article