SmartFACT Data can send chosen events to a system of your own, such as your ordering system, and your system tells Data what it did. In the first version there is one event: when a supervisor approves a supplier order in SmartFACT Purchasing, SmartFACT Data sends your system that order, and your system tells Data whether it placed it. Use this guide to set the connection up, to check it, to make it live and to look after it. Your developer builds the receiving side from Receive SmartFACT Data hooks. A connection to your own system is part of Data's paid service.
What a connection is
A connection is one HTTPS address on your system, the events that go to it, two keys, a technical contact and a record of every delivery. You find connections under Settings › Your systems. Everyone with a role at the site can read the page. Only an Owner sets a connection up, and only a reviewer makes it live. The technical contact's and Owners' email addresses show only to Owners, reviewers and supervisors.
Data only sends to your system, and your system only answers Data. Purchasing never holds your system's address or keys. Data passes your system's results back to Purchasing.
Each connection has one of six states, shown beside its name:
| State | What it means |
|---|---|
| Draft | Named, with no address yet. Nothing is sent. |
| Testing | An address is set. Only test events are sent. |
| Shadow | Real orders are sent to your system as a rehearsal. Purchasing still sends each order its usual way. |
| Live | Real orders are sent, and your system acts on them. |
| Paused | Nothing is sent. Events wait until an Owner resumes. |
| Retired | Kept for its history. Nothing is sent, and its keys are destroyed. |
A site can have at most 20 connections that are not retired. One connection at a time takes the site's supplier orders: from its shadow period, through live, and while it is paused from either, until it is retired. If another connection already does, the page names it and asks you to retire it first.
If a yellow notice at the top says that sending is switched off, or that the link to SmartFACT Purchasing or email is not set up, ask whoever looks after your SmartFACT installation. Without sending, nothing reaches your system.
Set a connection up
An Owner does this, and each step asks for a recent second factor. Press Confirm it's you when Data asks.
- Open Your systems. Under Connect a system, enter a Name of 3 to 100 characters, such as "Factory system", and press Create connection.
- Under Address, enter The HTTPS address of your system's receiver and press Save address. Data refuses an address it will not send to and says which rule it breaks (see the table below). Data checks the same rules again before every attempt, so an address that stops passing stops receiving.
- Data now shows two keys, once, under Copy the new key now: it is shown once. We sign with is the key Data signs every event with, and your system checks it. You sign with is the key your system signs every result with. Press Copy "we sign with" and Copy "you sign with", put each in your system's private settings, and press I have saved it, dismiss. Never put a key in an email, a shared document or code. Data keeps the keys encrypted and cannot show them again. If you lose one, change it (see below).
- Under Who is emailed, enter the Technical contact's name and email, and list the Owners to email, one address on each line (up to 10). SmartFACT Accounts does not give Data anybody's address, so only the Owners you list are emailed. Every Owner sees an alert on the page.
- Under What Data sends, and what your system tells Data, tick Supplier order to send. The same panel shows the Results address and the Catch-up read address to copy for your developer. See payload shows what the event looks like.
- Give your developer the two keys, the results address and the Code examples tab (see the second guide).
Data refuses an address in these cases:
| Rule | What to change |
|---|---|
| It is not a complete web address | Enter the whole address, starting with https. |
| It must start with https | Use an https address. |
| It carries a user name or password, or ends with a # part | Remove them. |
| It must use a name, not an IP address | Use a public name with a dot in it. |
| Its name must be a public one | Do not use localhost, .local or .internal. |
| Its port must be a plain number, 443 or from 1024 up | Remove the port, or use 443 or 1024 and above. |
| Its name cannot be found | Check the spelling and that the name is public. |
| Its name leads to a private or reserved address | Use a name that points to a public address. |
A system on the same server as SmartFACT is still reached by its public name. A connection never follows a redirect, because a redirect proves nothing about what your system kept.
Work through the checklist
Under Before it goes live, each item shows ✓ when met. An item that is not met links to where you put it right. Send test event (Owner, recent second factor) sends your system a signed test event, the same event signed with another key, and the same event again. Then your developer runs send-result from the example so that Data receives a signed result.
| Item | What it needs | What fixes it |
|---|---|---|
| Address passes the outbound checks | The address obeys every rule above. | Change address, under Address. |
| Contact set for failure emails | A technical contact is saved. | Change who is emailed. |
| Test event accepted | Your system answers the test event 2xx within 15 seconds. The item shows what it answered, such as "it answered 500", "it answered with a redirect, which is never followed", or "its name cannot be found". | Put right what your receiver answered, then press Send test event again. |
| Bad signature refused | Your system answers 401 or 403 to the same event signed with another key. If it accepts it, the item says "Your system accepted an event signed with another key". | Make the receiver check the signature on the raw body before it does anything else. |
| Test result received and verified | A signed result for the test event reaches the results address. | Run send-result from the example (the item links to Code examples). |
| Repeat answered | Your system answers the same event again, with the same webhook-id, 2xx. |
Store each event's id and answer a repeat with 2xx. |
The last two items belong to the next two sections. Shadow period and Reviewer's approval, with a second factor show ● and ✗ until they are done.
Start the shadow period and make it live
When the first six items are met, an Owner presses Start the shadow period. If another connection already takes this site's supplier orders, the button stays disabled until that one is retired.
In the shadow period Purchasing still sends each real order its usual way. Where its sending rule asks for a shadow copy, Data also sends your system that order, marked shadow. Your system does everything except the real-world action, such as building the file without sending it, and reports results as usual. Data keeps those results and passes nothing to Purchasing, so they never change an order.
There is no minimum period or number of orders. The checklist counts what has happened: "4 orders sent as shadow. Results: 3 placed, 1 refused, 0 none yet." It adds "n not accepted by your system" when your system has not taken some. Data is never told how the real send went, so it never says that a result agrees with it. A reviewer compares the shadow results with what Purchasing really sent.
When the results satisfy them, a reviewer opens the connection, writes Why it can go live (at least 10 characters) and presses Make live, with a recent second factor. The note and the counts at that moment are kept, and show on the page as "made it live on … : note". Everything Data sends from then is live.
Purchasing hears of every change of state. Its sending rules offer your system as a channel only while the connection is live, and offer a shadow copy while it is in shadow or live. Under Going live, and stopping the page says when Purchasing was told, or why it has not taken the state.
Change an address or the events
Change address and Save events each make a new version of the connection and put it back to Testing. The checklist runs again, and a reviewer makes it live again, so nobody can point a live connection somewhere else on their own. After the events change, the Code examples tab says the examples you downloaded are out of date. Download them again.
Events recorded before an address change wait. The Set-up tab says "n events were recorded before the address changed and wait here". An Owner presses Move them to the new address. Data sends what surely never reached the old address, in order. An order the old address may have is set aside and Purchasing is told that your system may have it, so one order never goes to two systems.
Change a key
Under Keys, press Change key "we sign with" or Change key "you sign with". Data shows the new key once. For seven days both keys work:
- We sign with: Data signs every event with both, as two signatures in one header. A receiver holding either key accepts it.
- You sign with: Data accepts a result signed with either key.
The page says "Changing: Data signs with both this key and whsec_…xxxx until you press Finish, or" the date. Your system holds one key at a time, so swap it at any point in the seven days, check that events and results flow, then press Finish changing "we sign with" (or "you sign with"). Only the new key works from then. After seven days Data ends the change itself. A key cannot be changed again until the first change is finished. A lost key is changed in the same way.
Read Deliveries
The Deliveries tab has one row for each event. Filter by All, Waiting, Stopped or Finished. A row shows the order reference, the event's number, any Shadow or Test label, and one of these phases:
| Phase | What it means |
|---|---|
| Waiting | Not yet tried, or behind an earlier event about the same order. |
| Being sent | An attempt is under way. |
| Retrying | Your system did not accept it. Data tries again, from 30 seconds later, doubling to every 30 minutes, for 72 hours. |
| Accepted | Your system answered 2xx. |
| Stopped | Data will not try again by itself. The row says why, such as "it answered 422". |
| Held for the new address | It was recorded before an address change and waits for Move them to the new address. |
| Set aside | A person, or Data, ended it. It is never sent again. |
A row shows how many attempts there were, when the next is due and what your system said, such as "Your system said: placed". Open Body and attempts of the order to see the exact body, its size and SHA-256, and for every attempt its time, answer, the headers Data sent and the first 1 KiB of your system's reply.
Data keeps the body, attempts and replies for 30 days. What was decided and reported stays.
Events about one order go in order. A later event about an order waits while an earlier one is waiting or stopped, and says "Waiting behind an earlier parked event about" the order. The stopped one says "n later events about it are waiting behind this one". Events about different orders never wait for each other.
What a supervisor can do
- Send again is offered only for a stopped shadow or test event. Data sends the same body with a fresh signature. It is never offered for a live supplier order, because that could place the order twice (see the next section).
- Set aside is offered for a waiting, stopped or held event. Enter Reason for setting it aside. The event is never sent again, and the later events about the same order go next. For a live order the page says Purchasing is told. For a shadow or test event the page says whether your system can still read it through the catch-up read: it can if it was sent once, and it cannot if it was never sent. Setting aside cannot be undone.
- Tell Purchasing about the order again is offered under SmartFACT Purchasing did not take these, where Purchasing refused an outcome Data passed on. Check the order in Purchasing first.
Orders that were not sent lists orders Purchasing asked for that never became an event, with the reason, such as the connection not being live or the order being too large.
What a stopped supplier order does in Purchasing
A live supplier order that stops is never sent from Data again, and holds up nothing behind it. It stops when your system answers with a refusal, when it keeps failing for 72 hours, when a supervisor sets it aside, when the connection is retired, or when it has waited in Data for four days. In one step Data sets the event aside and tells Purchasing, in one of two ways:
| Your system | Data tells Purchasing | Purchasing then |
|---|---|---|
| Surely has not got the order | It was not handed over | Offers another hand-over or an email at once. |
| Has it, or may have it | It was handed over, with the words "Your own system may have this order" | Waits four working hours for a result, then calls it unknown and asks a person. |
Your system may have an order after an attempt with no answer, a 408, a redirect or any 5xx, because a system can store an order and then fail. It surely has not got it only where nothing left Data, or every attempt got a refusal of its own, a 4xx other than 408. The row says which, and "Check your system for it" where it may.
So sending a stopped order again happens in Purchasing, as a new hand-over or another way, never from Data. A result your system sends for it afterwards is still stored and passed on. See Send orders through your own system for what a supervisor does there.
Pause and resume
An Owner, reviewer or supervisor can pause a testing, shadow or live connection: enter a Reason for pausing and press Pause. Stopping needs no second factor. Nothing is sent while it is paused, and events wait in order.
Only an Owner resumes it, with a recent second factor, by pressing Resume. Waiting events are then sent in their order. Data also pauses a connection by itself when your system answers 410 Gone, which means never send here again, and when SmartFACT Data has been restored from a backup. After a restore nothing live goes by itself: every live order not yet accepted is set aside, Purchasing is not told and asks a person, and shadow copies go on when you resume. Check what your system has received before you resume.
To end a connection for good, an Owner opens Retire this connection, writes a reason of at least 10 characters and presses Retire. It cannot be undone, its keys are destroyed, results are refused, and Purchasing is told what became of each order that was waiting.
Alerts
Data raises an alert, one for each connection, when your system has not accepted an event for 15 minutes, again at 24 hours, when an event first stops, and once a day while anything is stopped. A live order that stopped says what Purchasing was told and that it is never sent again from here. Nobody needs to act on that alert in Data, so it ends when your system accepts a later event, or after a day.
Alerts show at the top of the connection, as a count on its row in Your systems, and as a count on the menu item. They are emailed to the technical contact and the Owners you listed. If email is not set up on the installation, the page says "Not emailed: email is not configured on this installation". Test events raise no alert.
Check the results
The Results tab lists what your system told Data, newest first, with its reference and message. The last column says where each went: "Test: counted for the checklist", "Shadow: kept here and passed to nobody", "Passed on to SmartFACT Purchasing", or "SmartFACT Purchasing did not take it" with the reason. What has been done, on the Set-up tab, lists every change to the connection and who made it.